«

linux shell脚本学习录制与回放终端会话

时间:2024-3-2 15:33     作者:韩俊     分类: Linux



amosli@amosli-pc:~/learn$ script -t 2> timing.log -a output.session#开始录制
Script started, file is output.session
amosli@amosli-pc:~/learn$ hello1
No command 'hello1' found, did you mean:
Command 'hello' from package 'hello-debhelper' (main)
Command 'hello' from package 'hello' (main)
hello1: command not found
amosli@amosli-pc:~/learn$ who
amosli tty7 2013-12-19 22:58
amosli pts/1 2013-12-19 22:59 (:0.0)
amosli pts/2 2013-12-19 23:16 (:0.0)
amosli@amosli-pc:~/learn$ time

real 0m0.000s
user 0m0.000s
sys 0m0.000s
amosli@amosli-pc:~/learn$ date
2013年 12月 20日 星期五 01:06:41 CST
amosli@amosli-pc:~/learn$ exit
exit #结束录制
Script done, file is output.session



播放录制:


amosli@amosli-pc:~/learn$ scriptreplay timing.log output.session #按播放命令序列输出
amosli@amosli-pc:~/learn$ hello1
No command 'hello1' found, did you mean:
Command 'hello' from package 'hello-debhelper' (main)
Command 'hello' from package 'hello' (main)
hello1: command not found
amosli@amosli-pc:~/learn$ who
amosli tty7 2013-12-19 22:58
amosli pts/1 2013-12-19 22:59 (:0.0)
amosli pts/2 2013-12-19 23:16 (:0.0)
amosli@amosli-pc:~/learn$ time

real 0m0.000s
user 0m0.000s
sys 0m0.000s
amosli@amosli-pc:~/learn$ date
2013年 12月 20日 星期五 01:06:41 CST
amosli@amosli-pc:~/learn$ exit
amosli@amosli-pc:~/learn$

进行多个用户之间进行广播视频会话:打开两个终端

(1)在终端1中输入以下命令:


mkfifo scriptfifo

(2)在终端2中输入以下命令:


cat scriptfifo

(3)返回终端1,输入以下命令:


script -f scriptfifo
commands...

这样就实现了广播,在线课堂类的作用,非常神奇!!

我自己实验的输出:


终端1:
amosli@amosli-pc:~$ mkfifo scriptfifo
amosli@amosli-pc:~$ script -f scriptfifo
Script started, file is scriptfifo
amosli@amosli-pc:~$ who
amosli tty7 2013-12-19 22:58
amosli pts/1 2013-12-19 22:59 (:0.0)
amosli pts/2 2013-12-20 01:14 (:0.0)
amosli pts/4 2013-12-20 01:16 (:0.0)
amosli pts/5 2013-12-20 01:20 (:0.0)
amosli pts/6 2013-12-20 01:20 (:0.0)
amosli@amosli-pc:~$

终端2:
amosli@amosli-pc:~$ cat scriptfifo
Script started on 2013年12月20日 星期五 01时21分19秒
amosli@amosli-pc:~$ who
amosli tty7 2013-12-19 22:58
amosli pts/1 2013-12-19 22:59 (:0.0)
amosli pts/2 2013-12-20 01:14 (:0.0)
amosli pts/4 2013-12-20 01:16 (:0.0)
amosli pts/5 2013-12-20 01:20 (:0.0)
amosli pts/6 2013-12-20 01:20 (:0.0)
amosli@amosli-pc:~$

标签: linux

热门推荐