http://bbs.51cto.com/thread-594667-1.html  script使用注意事项
输入1:
[root@-shiyan rec]# cat record1
#!/bin/bash
#Filename:Record.sh dir=/tmp/rec
read -p "Please input the session filename: " filename
sesfile="$dir/$filename.session"
logfile="$dir/$filename.timing.log" if [ -e $sesfile ]
then
echo "$sesfile is Exsit,Creat session file fault!"
read -p "If you want to reload the file? [Y/N]: " flag
if [ "$flag" = "Y" ]
then
rm $sesfile $logfile
script -t > $logfile -a $sesfile
else
echo "Nothing to do!"
fi
else
script -t > $logfile -a $sesfile
fi 输入2:
[root@-shiyan rec]# cat replay1
#!/bin/bash
#Filename:Replay.sh
dir=/tmp/rec/
read -p "Please input the session filename: " filename
logfile="$dir$filename.timing.log"
sesfile="$dir$filename.session"
if [ -e $sesfile ]
then
scriptreplay $logfile $sesfile
echo
else
echo "$filename is NOT Exsit!"
fi 记录:
[root@-shiyan rec]# bash record1
Please input the session filename: uu
Script started, file is /tmp/rec/uu.session [root@-shiyan rec]# exit
exit
Script done, file is /tmp/rec/uu.session 回放:
[root@-shiyan rec]# bash replay1
Please input the session filename: uu
[root@-shiyan ~]# cat >>/etc/profile
source /root/jjj
[root@-shiyan ~]# ll /tmp/history/root/
total
-rw------- root root Feb : 192.168.2.84.history.20150212_104033
-rw------- root root Feb : 192.168.2.84.history.20150212_104036
-rw------- root root Feb : 192.168.2.84.history.20150212_104111
[root@-shiyan ~]# cat jjj
USER_IP=`who -m >/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
if [ ! -d /tmp/history ]
then
mkdir /tmp/history
chmod /tmp/history
fi
if [ ! -d /tmp/history/${LOGNAME} ]
then
mkdir /tmp/history/${LOGNAME}
chmod /tmp/history/${LOGNAME}
fi
export HISTSIZE=
DT=`date +"%Y%m%d_%H%M%S"`
export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP}.history.$DT"
chmod /tmp/history/${LOGNAME}/*history* 2>/dev/null

shell脚本实例-命令记录的更多相关文章

  1. 分享7个shell脚本实例--shell脚本练习必备

    概述 看多shell脚本实例自然就会有shell脚本的编写思路了,所以我一般比较推荐看脚本实例来练习shell脚本.下面分享几个shell脚本实例. 1.监测Nginx访问日志502情况,并做相应动作 ...

  2. linux 执行远程linux上的shell脚本或者命令以及scp 上传文件到ftp--免密码登陆

    场景:在linux A 上执行Linux B上的shell脚本和命令 步骤1.设置ssh免登陆 1.SSH无密码登录 # 本地服务器执行(A机器):生成密钥对 ssh-keygen -t dsa -P ...

  3. shell 脚本控制命令的执行顺序

    &&,||,(),{},& 五个符号的运用shell脚本执行命令的时候,有时候会依赖于前一个命令是否执行成功.而&&和||就是用来判断前一个命令执行效果的. 也 ...

  4. shell脚本实例,通向shell脚本大师的必经之路

    概述 读书百遍其义自见,shell脚本也是,只要例子看得多了,自然就知道怎么写了.这里主要整理了20几个例子,因为内容比较多,所以分了几次来做介绍了.下面的实例最好先自己思考怎么去实现,然后再看下实现 ...

  5. shell脚本实例-系统监控

    shell脚本监控网站并实现邮件.短信报警shell进程监控脚本(发送邮件报警)Shell脚本监控服务器在线状态和邮件报警的方法 http://www.jbxue.com/jb/shell/ 11. ...

  6. Shell 脚本常用命令

    Shell脚本是Linux开发工作中常用的工具,但是我一直没有找到一个适合自己的简明扼要的HandBook.在工作过程中整理了一下,贴在这里已备查看. 1           Shell中的特殊符号 ...

  7. 用 shell 脚本做命令行工具扩展

    问题的提出 公司开发机与远程服务器之间有严格的隔离策略,不能直接使用 ssh 登录,而必需通过跳板机.这样一来,本地与服务器之间的一些文件传输变得非常不便.经过咨询,运维教了我一招: $ nc -l ...

  8. Linux之Shell脚本计算命令行的所有和

    问题:设计一个Shell脚本:求命令行上所有整数和 Shell代码: 调用add.sh脚本结果:

  9. Makefile Shell 脚本;sed命令

    1. 在Makefile中想使用shell脚本,需要添加"@"符号,例如: @if [ -d xxx ]; then \                        //-d 判 ...

随机推荐

  1. 技术分享:如何用Solr搭建大数据查询平台

    0×00 开头照例扯淡 自从各种脱裤门事件开始层出不穷,在下就学乖了,各个地方的密码全都改成不一样的,重要帐号的密码定期更换,生怕被人社出祖宗十八代的我,甚至开始用起了假名字,我给自己起一新网名”兴才 ...

  2. OpenSesame:一个能够攻击fixed-pin设备的工具

    OpenSesame是一种设备,这种设备可以通过无线技术来打开任何一个设有固定密码的车库门,我从中发现了一个攻击无线固定pin码设备的新方法. 演示视频以及详细信息: opensesame源代码:ht ...

  3. 第一个PHP程序

    <html> <head> <title><?php echo"这是第一个php程序"?></title> <st ...

  4. C# INotifyPropertyChanged

    INotifyPropertyChanged 向客户端发出某一属性值已更改的通知. namespace System.ComponentModel{ // Summary: // Notifies c ...

  5. HDU1556-color the ball(线段树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556 #include<cstdio> using namespace std; stru ...

  6. Inno_setup制作升级包必须面临的几个问题

    Inno_setup制作升级包必须面临的几个问题 分类: c/c++/GamingAnyWhere JavaScript linux shell基础知识 2013-12-18 22:14 1496人阅 ...

  7. 通过.htaccess文件让Magento加速

    Magento提速的方法很多,通 过.htaccess文件开启GZip压缩可以非常明显的让Magento加速.在Magento初始安装中已经包含了.htaccess文件,我们只需 要把.htacces ...

  8. 101+ Manual and Automation Software Testing Interview Questions and Answers

    101+ Manual and Automation Software Testing Interview Questions and Answers http://www.softwaretesti ...

  9. usb serial for android

    /******************************************************************** * usb serial for android * 说明: ...

  10. Maven打包可执行Jar包方式

    第一步:pom.xm中的build标签下加入maven插件配置,打包生成可执行jar包方式Maven中的打包方式更换为 <packaging>jar</packaging> b ...