>> On Wed, 08 Sep 2010 12:52:05 -0400 (EDT), Alois Mahdal wrote: A> I wonder if there's a simple and universal way to dump output of A> terminal to a file, particularly for demonstration purposes.
>> On Wed, 8 Sep 2010 13:35:30 -0400 (EDT), Stephen Powell >> <[email protected]> said: S> Well, for recording a shell session, there is "script". And to play it S> back later, there is "scriptreplay". [...] I don't know if that's what S> you want, though. script puts *everything* in the capture file, S> including linefeeds, backspaces, ANSI escape sequences, etc. For S> example, colorized output from "ls" results in ANSI escape sequences. I use a wrapper called "saveon" which tries to correct the worst results from "script" putting everything in the capture file: #!/bin/sh PATH=/bin:/usr/bin:/usr/local/bin SAVEON=1 export PATH SAVEON case "`whoami`" in root) prompt='root#' ;; *) prompt='me%' ;; esac export PS1=" $prompt " tmp=`mktemp /tmp/$tag.XXXXXX` || { echo "$tag: mktemp failed" >&2; exit 1 } trap "rm -f $tmp; exit 0" 0 1 2 3 15 sedscr=' s/^.*script-is-done:// s/^.*script-started-on:// /Script started on /d /^me% *$/d /^me% exit$/d /^root# *$/d ' echo "script-started-on:`date '+%a %b %d %T %Y'`" > $tmp script -c /bin/sh -a -q $tmp echo "script-is-done:`date '+%a %b %d %T %Y'`" >> $tmp col -b < $tmp | sed -e "$sedscr" > typescript exit 0 * The date commands give me a consistently-formatted start and finish time at the top and bottom of "typescript". * The newline in the prompt cleanly separates commands from output. * "col -b" gets rid of at least some special characters. * The SAVEON environment variable lets me set programs to show colors or mess with terminal settings only when it makes sense to do so. For example, my "dir" script looks like this: #!/bin/sh case "$SAVEON" in "") opt='--color=auto' ;; *) opt='' ;; esac unset BLOCK_SIZE # throws off the results. exec ls -lF $opt ${1+"$@"} -- Karl Vogel I don't speak for the USAF or my company You do not need a parachute to skydive. You only need a parachute to skydive twice. -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: http://lists.debian.org/[email protected]

