Using script(1) to capture console output

wblock@

Developer
script(1) can be used to capture console session output. This is useful for later reference, like looking for what caused a port to fail to build.

Example:
Code:
# script /tmp/session.txt
# cd /usr/ports/www/links
# make
...
# exit

Script done, output file is /tmp/session.txt

Everything that was shown on the screen is captured in the output file /tmp/session.txt.
 
jb_fvwm2 said:
One can also use tee or sysutils/Tee similarly
Code:
man tee && man Tee
if the latter installed. A third exists but is in sysutils/moreutils and I am unsure of how it is precisely useful in this case (The first post).

One difference between script(1) and tee(1) is that script captures everything, stdin, stderr, even the control characters typed or output. tee(1) only captures stdin, not everything. Of course, you can redirect, but script(1) is already there. And it's in the base system.
 
As a minor note, the rprompt option in tcsh screws up any output from script(1), so be sure to disable this.
 
Nah, only for those who view typescript files as plain text in dumb terminals. less(1) have -r and -R options to render terminal control sequences.

One can also record session with timestamps using -r option (cf. script(1) on NetBSD). It can later be played using -p option, e.g. to observe how user interacted with ncurses application such (nvi(1), tcsh(1)'s tab-completion, etc.). A few years back there were plenty of recorded howtos on youterm.com, mostly for radare, that could be viewed either via telnet or java applet. The feature is ported to FreeBSD in PR bin/114465.
 
Back
Top