运行各种安装脚本时记录终端

发布于 2024-11-15 11:00:05 字数 206 浏览 0 评论 0原文

我在 shell 中编写了一个安装脚本,它对各种东西(例如 xserver、网络等)进行了一些配置,然后安装了一些 RPM,这是没有问题的。但我也希望能够记录进入终端屏幕的所有内容。这是否可以在脚本内完成,因此如果最终用户运行 ./Install.sh 它将执行所有操作(包括日志记录)。

我尝试过使用“脚本”,但在 Install.sh 脚本本身中不起作用。

谢谢

I have written an install script in shell that does some configuration of various things such as xserver, network, etc and then installs a few RPM's which is no problem. But I want to be able to log everything that goes to the terminal screen as well. Is this possible to do from within the script so if the end user runs ./Install.sh it will do everything (including the logging).

I have tried using "script" but doesn't work from within the Install.sh script itself.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只需使用:

script logfilename install.sh

当 install.sh 完成运行时,script 也结束 - 因此,您可以将所有内容记录到 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.

Just use:

script logfilename install.sh

when the install.sh finished the run, the script end too - so, you get everything logged into logfilename.

Probably you can make it two-stage, so, you should rename your current install.sh into install-stage2.sh and your install.sh will contain:

script ./install.log ./install-stage2.sh

UPDATE from my 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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文