1
我已经在shell中编写了一个安装脚本,用于执行xserver,network等各种配置的一些配置,然后安装几个RPM,这是没有问题的。但我希望能够记录进入终端屏幕的所有内容。这是否可以在脚本中完成,因此如果最终用户运行./Install.sh,它将执行所有操作(包括日志记录)。在运行各种安装脚本时记录终端
我已经尝试使用“脚本”,但不能从Install.sh脚本本身中工作。
感谢
我已经在shell中编写了一个安装脚本,用于执行xserver,network等各种配置的一些配置,然后安装几个RPM,这是没有问题的。但我希望能够记录进入终端屏幕的所有内容。这是否可以在脚本中完成,因此如果最终用户运行./Install.sh,它将执行所有操作(包括日志记录)。在运行各种安装脚本时记录终端
我已经尝试使用“脚本”,但不能从Install.sh脚本本身中工作。
感谢
只需使用:
script logfilename install.sh
当install.sh完成来看,script
结束 - 所以,你得到的一切登录到logfilename
。
也许你可以把它两阶段,所以,你应该将当前install.sh
重命名为install-stage2.sh
,你的install.sh将包含:
script ./install.log ./install-stage2.sh
UPDATE从我man script
NAME
script -- make typescript of terminal session
SYNOPSIS
script [-akq] [-t time] [file [command ...]]
DESCRIPTION
The script utility 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.
If the argument command is given, script will run the specified command with an optional argument vector instead
of an interactive shell.
尝试了脚本log.log没有运气的Install.sh,它似乎根本没有启动脚本。 – Danny 2011-06-15 14:58:25
奇怪 - 因为从我的'man script' - 请参阅编辑 – jm666 2011-06-15 19:42:11