Linux script and scriptreplay(一)
2016-04-25 20:56
381 查看
前言
偶然发现linux里面两个比较有意思的命令script和scriptreplay,其中script是用来录制命令的,scriptreplay用来重放录制文件。机器为ubuntu。script和scriptreplay的使用
看一下script的帮助文档script -h Usage: script [options] [file] Options: -a, --append append the output -c, --command <command> run command rather than interactive shell -r, --return return exit code of the child process -f, --flush run flush after each write --force use output file even when it is a link -q, --quiet be quiet -t, --timing[=<file>] output timing data to stderr (or to FILE) -V, --version output version information and exit -h, --help display this help and exit
使用script
script -t out.data 2>out.time #以上2>out.time表示将stderr重定向到out.time文件中 #之后随意输入命令 #最后输入ctrl+d退出
scriptreplay帮助文档
scriptreplay -h Usage: scriptreplay [-t] timingfile [typescript] [divisor] Options: -t, --timing <file> script timing output file -s, --typescript <file> script terminal session output file -d, --divisor <num> speed up or slow down execution with time divisor -V, --version output version information and exit -h, --help display this help and exit
使用scriptreplay重放命令
scriptreplay -t out.time out.data
下载script和scriptreplay源码
找到script的位置#找到script的位置 which script /usr/bin/script #查看找到的文件是否是软连接,是则继续找 ls -l /usr/bin/script -rwxr-xr-x 1 root root 14760 Aug 5 2015 /usr/bin/script
找到script属于哪个包
dpkg -S /usr/bin/script bsdutils: /usr/bin/script #script属于bsdutils这个包的
下载bsdutils源码
sudo apt-get source bsdutils ls -l #这里已经下载好了 drwxr-xr-x 31 root root 4096 Apr 17 15:55 util-linux-2.20.1 -rw-r--r-- 1 root root 117861 Sep 3 2015 util-linux_2.20.1-5.1ubuntu20.7.diff.gz -rw-r--r-- 1 root root 3257 Sep 3 2015 util-linux_2.20.1-5.1ubuntu20.7.dsc -rw-r--r-- 1 root root 6174190 Dec 17 2011 util-linux_2.20.1.orig.tar.gz
查找script所在位置
find -L util-linux-2.20.1 -name "*script*" #以下是结果,现在可以去查看相关源代码了 util-linux-2.20.1/debian/README.script util-linux-2.20.1/term-utils/script.c util-linux-2.20.1/term-utils/script.1 util-linux-2.20.1/term-utils/scriptreplay.c util-linux-2.20.1/term-utils/scriptreplay.1 util-linux-2.20.1/tests/expected/script util-linux-2.20.1/tests/ts/script
重新编译script
用apt-get安装依赖sudo apt-get build-dep bsdutils
编译
./configure make
相关文章推荐
- centos7中的lamp的快速搭建
- linux内存源码分析 - 内存压缩(同步关系)
- 0041 linux 下配置安装mysql以及配置
- Linux下网卡eth1如何修改为eth0
- 每天一个linux命令:chgrp
- 关于linux硬盘分区的简单方法
- scanf那些事
- 如何使用Linux的Crontab定时执行PHP脚本的方法
- 每天一个linux命令:chown
- 有趣的linux文件bb
- 【Linux】UNDERSTANDING LINUX CPU LOAD - WHEN SHOULD YOU BE WORRIED?
- 【Linux C 王者归来】【第四章】【指针与字符串】
- CentOS7安装vncserver(启动失败及连接黑屏解决办法)
- CentOS下安装setuptools、pip和virtualenv
- CentOS 6.5环境使用ansible剧本自动化部署Corosync + pacemaker环境及corosync常用配置详解
- Linux 大于2T 解决方法
- CentOS 6.5环境使用ansible剧本自动化部署Corosync + pacemaker环境及corosync常用配置详解
- 试试Linux下的ip命令,ifconfig已经过时了
- linux 虚拟机详细搭建过程
- linux读写锁