标签:war style ref span -- /tmp 时间段 code nbsp
使用script命令录制,使用scriptreplay播放录制的操作。共享终端的操作,则需要使用命名管道来实现。
[root@xuexi ~]# cd /tmp [root@xuexi tmp]# script -t 2> timing.log -a output.session # 开始录制 Script started, file is output.session
[root@xuexi tmp]# ls # 执行一个操作:命令ls abc.sh ab.sh index.html lost+found output.session scriptfifo test test1 timing.log vmware-root [root@xuexi tmp]# cd /tmp/test # 再执行一个操作:命令cd
[root@xuexi test]# exit # 结束录制 exit Script done, file is output.session
其中"-t 2> timing.log"是要回放的必须选项,不加"2>"将导致开启录制后的任何输入都是乱码状态,不加"-t timing.log"将不能使用scriptreplay来回放。timing.log记录的是每个时间段输入了多少字符。通过timing.log和output.session配合可以实现回放。
注意点是,录制前保证timing.log和output.session是空文件,否则将导致回放时操作不一致。
[root@xuexi test]# scriptreplay timing.log output.session
通过管道来传输信息实现。需要一个pipe文件,并在需要展示的终端打开这个管道文件。
在终端1(作为主终端,即演示操作的终端)上使用mkfifo创建管道文件。
[root@xuexi tmp]# mkfifo scriptfifo [root@xuexi tmp]# ll scriptfifo prw-r--r-- 1 root root 0 Sep 26 13:04 scriptfifo # 权限位前面的第一个p代表的就是pipe文件。
在终端2上打开pipe文件。
[root@xuexi ~]# cat /tmp/scriptfifo
在终端1上使用script -f开始记录操作,之后的操作将会分享在终端2上。
[root@xuexi tmp]# script -f scriptfifo
使用exit即可停止分享并退出记录行为。
[root@xuexi tmp]# exit exit Script done, file is scriptfifo
在被分享终端上参与分享状态后将不能执行任何操作,执行的操作会被记录下来,并在主终端停止分享后自动执行。
回到系列文章大纲:http://www.cnblogs.com/f-ck-need-u/p/7048359.html
标签:war style ref span -- /tmp 时间段 code nbsp
原文地址:http://www.cnblogs.com/f-ck-need-u/p/7429520.html