What is "script" command?
script
is a very useful command that can be used to capture all that appears on a terminal. The output thus captured from the interactive session may then be useful while sharing with another colleague or team, or even used in a variety of debugging scenarios.Next time you find yourself in a position to grab the screen/terminal contents, make use of this wonderful utility instead of relying on ad-hoc output redirections and screenshot captures.
What is its syntax and how do I use it?
Refer to the man pages on your system for the exact syntax/details, or an online resource like the one at http://unixhelp.ed.ac.uk/CGI/man-cgi?script. Typical usage however is along the lines of:
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]
Are there any interesting points to be noted?
One standard note is that interactive commands, such as vi, create garbage in the output file. Be aware of it as such and use "script" for capturing plain text.
Few oft missed aspects, though, are that it:
- Invokes a new shell based on what is populated in the environment variable
SHELL
- Creates a new login session as can be seen from the output of
last
command
Why don't you show me a simple invocation and what does it result in?
Sure, I can :)
Here's a sample invocation of the command:
sh-3.2# script Script started, file is typescript sh-3.2# ls bin boot dev etc home lib lib64 lost+found media misc mnt net opt proc root sbin selinux srv sys tftpboot tmp typescript usr var sh-3.2# exit exit Script done, file is typescriptAnd, this is what is logged into the file:
sh-3.2# cat typescript Script started on Tue 23 Jul 2013 04:10:04 PM IST sh-3.2# ls bin boot dev etc home lib lib64 lost+found media misc mnt net opt proc root sbin selinux srv sys tftpboot tmp typescript usr var sh-3.2# exit exit Script done on Tue 23 Jul 2013 04:10:20 PM IST sh-3.2#
No comments:
Post a Comment