码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本实例之命令记录

时间:2015-02-12 10:26:39      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

 

输入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

 

shell脚本实例之命令记录

标签:

原文地址:http://www.cnblogs.com/createyuan/p/4287388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!