shell脚本实例之命令记录

 

输入1:
[root@250-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 2> $logfile -a $sesfile
    else
     echo "Nothing to do!"
    fi
else
 script -t 2> $logfile -a $sesfile
fi

输入2:
[root@250-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@250-shiyan rec]# bash record1
Please input the session filename: uu
Script started, file is /tmp/rec/uu.session

[root@250-shiyan rec]# exit
exit
Script done, file is /tmp/rec/uu.session

回放:
[root@250-shiyan rec]# bash replay1
Please input the session filename: uu

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。