请输入您要查询的百科知识:

 

词条 Script (Unix)
释义

  1. Alternatives to Script Command

     Bourne shell 

  2. See also

  3. References

{{lowercase}}

The script command is a Unix utility that records a terminal session.[1] The scriptreplay command offers a replay function to script.[2] The session is captured in file name typescript by default; to specify a different filename follow the script command with a space and the filename as such: script recorded_session.

The ttyrec program provides the same kind of functionality and offers several bindings.

Recorded shell sessions can be shared using online services.[3] The advantage of sessions recorded in this format from the usual screencasts is that shell instructions can be easily copy/pasted from the player screen.

Alternatives to Script Command

One of the problems with the script command is that it only allows logging of a child process; and often there is a need to log the command in the current process without spawning a new process, such as when automation of a script is needed that can log its own output. The unix operating system makes this possible by use of pipes and redirects. Consider the following model examples:

Bourne shell

All shells related to Bourne shell (namely: sh, bash, and ksh) allow the stdout and stderr to be attached to a named pipe and redirected to the tee command.

Example

LOGNAME="script"

rm -f $LOGNAME.p $LOGNAME.log

mknod $LOGNAME.p p

tee <$LOGNAME.p $LOGNAME.log &

exec >$LOGNAME.p 2>&1

The above script records to script.log all output of the "exec" command. However, some interactive programs (such as python) do not display their standard input when run under the resulting shell, although they do when run under the script command.

See also

  • Command line interpreter
  • Shebang (Unix)
  • Bourne shell
  • Bourne-Again shell
  • C shell
  • Python (programming language)
  • Filename extension, Command Name Issues section
  • Perl
  • Scripting language
  • Unix shell

References

1. ^http://www.freebsd.org/cgi/man.cgi?query=script
2. ^LinuxInsight - Replaying terminal sessions with scriptreplay
3. ^The instructions at this link no longer work due to the demise of the shelr.tv service. OMG! Ubuntu! - How To Record And Share Terminal Screencasts Quickly
{{unix-stub}}

1 : Unix software

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 6:32:00