Shell 运行各种安装脚本时记录终端
我已经在shell中编写了一个安装脚本,它可以对各种事情进行一些配置,比如xserver、网络等,然后安装一些RPM,这是没有问题的。但是我也希望能够记录所有进入终端屏幕的内容。这是否可以从脚本中执行,因此如果最终用户运行./Install.sh,它将执行所有操作(包括日志记录) 我尝试过使用“script”,但在Install.sh脚本本身中不起作用 谢谢只需使用:Shell 运行各种安装脚本时记录终端,shell,logging,Shell,Logging,我已经在shell中编写了一个安装脚本,它可以对各种事情进行一些配置,比如xserver、网络等,然后安装一些RPM,这是没有问题的。但是我也希望能够记录所有进入终端屏幕的内容。这是否可以从脚本中执行,因此如果最终用户运行./Install.sh,它将执行所有操作(包括日志记录) 我尝试过使用“script”,但在Install.sh脚本本身中不起作用 谢谢只需使用: script logfilename install.sh 当install.sh完成运行时,脚本也结束了-因此,您可以将所有
script logfilename install.sh
当install.sh完成运行时,脚本
也结束了-因此,您可以将所有内容都登录到logfilename
可能您可以将其分为两个阶段,因此,您应该将当前的install.sh
重命名为install-stage2.sh
,并且您的install.sh将包含:
script ./install.log ./install-stage2.sh
从我的man脚本更新
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.
只需使用:
script logfilename install.sh
当install.sh完成运行时,脚本
也结束了-因此,您可以将所有内容都登录到logfilename
可能您可以将其分为两个阶段,因此,您应该将当前的install.sh
重命名为install-stage2.sh
,并且您的install.sh将包含:
script ./install.log ./install-stage2.sh
从我的man脚本更新
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时运气不佳,似乎根本无法启动脚本。尝试脚本log.log Install.sh时运气不佳,似乎根本无法启动脚本。