script命令

script命令最近用的较多,感觉蛮不错。script是将终端的会话过程录制下来的小工具,你在终端中的所有操作过程,都可以原原本本地进行录制。

先man一下:

SCRIPT(1) BSD General Commands Manual SCRIPT(1)

NAME
script - make typescript of terminal session

SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of
an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the
file typescript.

Options:

-a Append the output to file or typescript, retaining the prior contents.

-c COMMAND
Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a pro-
gram that behaves differently when its stdout is not a tty.

-f Flush output after each write. This is nice for telecooperation: One person does 'mkfifo foo; script -f foo' and
another can supervise real-time what is being done using 'cat foo'.

-q Be quiet.

-t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indi-
cates how much time elapsed since the previous output. The second field indicates how many characters were output
this time. This information can be used to replay typescripts with realistic typing and output delays.

The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if
ignoreeof is not set) for the C-shell, csh(1)).

Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do
not manipulate the screen, the results are meant to emulate a hardcopy terminal.

ENVIRONMENT
The following environment variable is utilized by script:

SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is
assumed. (Most shells set this variable automatically).

SEE ALSO
csh(1) (for the history mechanism), replay(1).

HISTORY
The script command appeared in 3.0BSD.

BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.

Linux July 30, 2000 Linux

用法:

script -a filename1 -t 2>filename2

退出命令:exit

若要察看记录结果,用cat filename即可

-a 用于将记录append到文件filename1,若不用则覆盖

-t可以记录每次敲击键盘的cpu时间,蛮有用的。比如做批处理等,通过察看filename2找到两次间隔时间很大的就可是作业执行的准确时间

filename1 filename2可以是同一个文件。

以上仅限于使用经验,对man没有深究,若有更好的使用方法,请高手不吝指教,呵呵

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值