开发者

Logging terminal while running an install script of sorts

I have written an install script in shell that does some configuration of various thi开发者_如何学编程ngs 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


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜