View Full Version : Using script(1) to capture console output
wblock@
August 27th, 2010, 19:09
script 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:
# 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.
Caliante
October 10th, 2010, 17:29
Excellent, this helped me already :P
Thank you ;)
jb_fvwm2
October 11th, 2010, 00:57
One can also use tee or sysutils/Tee similarly
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).
wblock@
November 4th, 2010, 00:25
One can also use tee or sysutils/Tee similarly
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 and tee is that script captures everything, stdin, stderr, even the control characters typed or output. tee only captures stdin, not everything. Of course, you can redirect, but script is already there. And it's in the base system.
Carpetsmoker
November 13th, 2010, 22:14
As a minor note, the rprompt option in tcsh screws up any output from script(1), so be sure to disable this.
eye
November 17th, 2010, 02:28
Nah, only for those who view typescript files as plain text in dumb terminals. less have -r and -R options to render terminal control sequences.
One can also record session with timestamps using -r option (cf. script(1) (http://netbsd.gw.com/cgi-bin/man-cgi?script+1+NetBSD-current) on NetBSD). It can later be played using -p option, e.g. to observe how user interacted with ncurses application such (nvi, tcsh's tab-completion, etc.). A few years back there were plenty of recorded howtos on youterm.com (http://web.archive.org/web/20080401074904/http://youterm.com/), mostly for radare (http://radare.nopcode.org), that could be viewed either via telnet or java applet. The feature is ported to FreeBSD in bin/114465.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.