from small one page howto to huge articles all in one place
poll results
Last additions:
May 25th. 2007:
April, 26th. 2006:
| 
.  You are here: System->Tips and Tricks
Using scriptThis tip shows you how to use script as a way to store or share everything printed during a terminal session. This can be a great way to remotely demonstrate command-line Linux to a less experienced user. Alternatively, it's a good way to keep a record of everything you do (or did) for a specific session. First we'll look at keeping a record of everything. The can be done by just issuing the command script. The output of your session will be written to a file named typescript. If you want to specify a file other than the default, use script file where file is the name of the file storing the session. Code Listing 1: Creating a script session % script
Script started, file is typescript
% uptime
13:27:53 up 89 days, 3:50, 1 user, load average: 0.27, 0.35, 0.29
% uname -srvmpio
Linux 2.4.20-gentoo-r4 #1 SMP Fri May 9 08:54:35 EDT 2003 i686 Intel(R) Xeon(TM)
CPU 2.00GHz GenuineIntel GNU/Linux
% exit
Script done, file is typescript The session file can be reviewed later with a pager such as more, less, or cat. Code Listing 2: Viewing a script session % more typescript
Script started on Wed Aug 6 13:27:47 2003
% uptime
13:27:53 up 89 days, 3:50, 1 user, load average: 0.27, 0.35, 0.29
% uname -srvmpio
Linux 2.4.20-gentoo-r4 #1 SMP Fri May 9 08:54:35 EDT 2003 i686 Intel(R) Xeon(TM)
CPU 2.00GHz GenuineIntel GNU/Linux
% exit
Script done on Wed Aug 6 13:28:01 2003 Now we'll look at sharing a terminal session. The easiest way to do this is combining script with mkfifo (which creates a named pipe). Note that you need to use the -f option (script -f) to flush output after each write. This way, the terminal can be written to by User A and viewed in (near) real time by User B. Code Listing 3: User A's terminal % mkfifo demo; script -f demo
Script started, file is demo
% echo 'Hello World'
Hello World
% exit
Script done, file is demo
Note: User A's terminal will wait for input until User B issues the cat command (or accesses the named pipe).Code Listing 4: User B's terminal % cat demo
Script started on Wed Aug 6 13:48:51 2003
% echo 'Hello World'
Hello World
% exit
Script done on Wed Aug 6 13:49:04 2003 There are many other ways script could be used - hopefully this will give you some ideas to get you started. From http://www.gentoo.org/news/en/gwn/20030811-newsletter.xml
rate this article: current rating: average rating: 1.3 (49 votes) (1=very good 6=terrible) Your rating:
back Support this site
|