?

Log in

No account? Create an account
 
 
19 April 2009 @ 11:35 am
script-declutter: clean up detritus that shows up when you run script  
You can download script-declutter from http://impson.tzo.com/~jdimpson/bin/script-declutter.

Hey, if you aren't a regular Unix command-line user, and don't know what the "script" command is for, you probably won't like this article.

I'll finish up my socat series later. For now, here's a short and clever little script. I'm sure someone has done this before, but it was fun implementing myself.

There's a traditional Unix command called script. According to its manpage,


Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.


When script was first introduced (some time in 1980), it was born in an environment where the GUI was not ubiquitous, where several users would log in to the same computer concurrently, and the majority of the software the user ran would be from shell command line. The script command, which can be used to save both the input from the user, and the output from the commands, was very useful to create a transcript, sometimes called a typescript, of a user's interactive session.

It's important to realize that script records the characters verbatim. For example, say a user meant to type "ls" but accidentally typed "la". He realizes his mistake and hits the backspace key to erase the "a", then typed "s". In this example, the script command would record "la^Hs" in the typescript file. The "^H" is not meant to be a caret ("^") followed by a capital H, but instead is one way to represent the single, otherwise non-printable Control Character (in the ASCII character set) that means "delete one character where the cursor is currently".

The manpage goes on to say,

Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal.


vi isn't the only thing that can cause escape sequences and control characters to be captured in a typescript file. User's of the bash shell (which includes almost every Linux user) usually have an environment variable called PROMPT_COMMAND set in such a way that it sets the title of an xterm terminal according to the current working directory, username, and hostname. On my Ubuntu 8.04 system,


jdimpson@freedom:~$ echo $PROMPT_COMMAND
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"


The "\033]0;" and "\007" are Escape Sequences that, when printed to the screen, tell the terminal program not to print something, but to modifiy the title bar, according to what's in between the two escape codes. However, the typescript file created by the script command will record the escape sequences.

The specific details of non-printable characters (both Escape Sequences and Control Characters) is beyond where I want to take this article. The following links can get you started with the theory of what's going on:



If you use "cat" or "less" or "more" to look at the contents of a script-generated typescript file, you probably won't notice any of these non-printable characters. That's because, on playback, the escape and control commands in the typescript file will get played back just like the regular text. However, if you were to use certain editors (like vim or even Microsoft Wordpad) you'll see the funny characters, although what you see will vary depending on how each editor decide to portray non-printable characters.

If you want to put a typescript file on-line somewhere, or send it as an email attachment, and you can't be sure who or what will be viewing the file, you'll want to strip out the non-printables. On top of that, you'll probably also want to see the final state of the file, after all backspaces and similar control characters have been processed. In other words, you want "la^Hs" to be converted to "ls" not "las". This means resolving all the control character and escape sequence commands. "script-declutter" tries to do this. It ain't perfect, but it's very effective.

Here's a very simple sample using the script command.

jdimpson@artoo:~$ script
Script started, file is typescript
jdimpson@artoo:~$ echo hello
hello
jdimpson@artoo:~$ exit
exit
Script done, file is typescript
jdimpson@artoo:~$ cat typescript
Script started on Sun 19 Apr 2009 02:05:27 AM EDT
jdimpson@artoo:~$ echo hello
hello
jdimpson@artoo:~$ exit
exit

Script done on Sun 19 Apr 2009 02:05:35 AM EDT
jdimpson@artoo:~$


You can't see any of the control and escape characters, because I used cat to display the typescript file. But if I use vim, it looks like that:


Script started on Sun 19 Apr 2009 02:05:27 AM EDT
^[]0;jdimpson@artoo: ~^Gjdimpson@artoo:~$ he^H^[[K^H^[[Kecho hello^M
hello^M
^[]0;jdimpson@artoo: ~^Gjdimpson@artoo:~$ exit^M
exit^M

Script done on Sun 19 Apr 2009 02:05:35 AM EDT


Note that when you use cat to view the file, all the control and escape characters get interpretted by the terminal display. Here you can see that while I ultimately ran the command "echo hello", I started out by type "he", then backspaced and retyped the line. Note also the double printing of the command prompt, "jdimpson@artoo". The first is actually the PROMPT_COMMAND mentioned earlier, with the "^[]0;" being a representation of the output of the "\033];0" part. "\033" is the octal representation of ESCAPE, and "^[" is a somewhat common alternate way to depict ESCAPE. Note also that the end of every line ends with "^M", which is a way of depicting the carriage return character.

vim is one way to look at the actual file. Another tool you can use is "hexdump -C", which gives you this output:


jdimpson@artoo:~$ hexdump -C typescript
00000000 53 63 72 69 70 74 20 73 74 61 72 74 65 64 20 6f |Script started o|
00000010 6e 20 53 75 6e 20 31 39 20 41 70 72 20 32 30 30 |n Sun 19 Apr 200|
00000020 39 20 30 32 3a 30 35 3a 32 37 20 41 4d 20 45 44 |9 02:05:27 AM ED|
00000030 54 0a 1b 5d 30 3b 6a 64 69 6d 70 73 6f 6e 40 61 |T..]0;jdimpson@a|
00000040 72 74 6f 6f 3a 20 7e 07 6a 64 69 6d 70 73 6f 6e |rtoo: ~.jdimpson|
00000050 40 61 72 74 6f 6f 3a 7e 24 20 68 65 08 1b 5b 4b |@artoo:~$ he..[K|
00000060 08 1b 5b 4b 65 63 68 6f 20 68 65 6c 6c 6f 0d 0a |..[Kecho hello..|
00000070 68 65 6c 6c 6f 0d 0a 1b 5d 30 3b 6a 64 69 6d 70 |hello...]0;jdimp|
00000080 73 6f 6e 40 61 72 74 6f 6f 3a 20 7e 07 6a 64 69 |son@artoo: ~.jdi|
00000090 6d 70 73 6f 6e 40 61 72 74 6f 6f 3a 7e 24 20 65 |mpson@artoo:~$ e|
000000a0 78 69 74 0d 0a 65 78 69 74 0d 0a 0a 53 63 72 69 |xit..exit...Scri|
000000b0 70 74 20 64 6f 6e 65 20 6f 6e 20 53 75 6e 20 31 |pt done on Sun 1|
000000c0 39 20 41 70 72 20 32 30 30 39 20 30 32 3a 30 35 |9 Apr 2009 02:05|
000000d0 3a 33 35 20 41 4d 20 45 44 54 0a |:35 AM EDT.|
000000db


Again, you can see the control and escape characters, not only in some human-readable format (in the right-hand column), but also the hexadecimal representation (in the middle two columns). This is often less ambiguous, and is how I figured out all the values for the escape & control characters, as used in the script-declutter, which I'll show you in a minute. Hexdump prints the control characters as plain dots ("."). It does the same for the non-printable parts of the escape sequences (usually the escape character itself). Note that it also prints tabs and newlines as dots.

Here's how you would use script-declutter to clean up the typescript file:

jdimpson@artoo:~$ script-declutter typescript > out


And here's what it looks like in vim.

Script started on Sun 19 Apr 2009 02:05:27 AM EDT
jdimpson@artoo:~$ echo hello
hello
jdimpson@artoo:~$ exit
exit

Script done on Sun 19 Apr 2009 02:05:35 AM EDT


This looks just like the original file when printed to the screen via cat. Hexdump agrees.

jdimpson@artoo:~$ hexdump -C out
00000000 53 63 72 69 70 74 20 73 74 61 72 74 65 64 20 6f |Script started o|
00000010 6e 20 53 75 6e 20 31 39 20 41 70 72 20 32 30 30 |n Sun 19 Apr 200|
00000020 39 20 30 32 3a 30 35 3a 32 37 20 41 4d 20 45 44 |9 02:05:27 AM ED|
00000030 54 0a 6a 64 69 6d 70 73 6f 6e 40 61 72 74 6f 6f |T.jdimpson@artoo|
00000040 3a 7e 24 20 65 63 68 6f 20 68 65 6c 6c 6f 0a 68 |:~$ echo hello.h|
00000050 65 6c 6c 6f 0a 6a 64 69 6d 70 73 6f 6e 40 61 72 |ello.jdimpson@ar|
00000060 74 6f 6f 3a 7e 24 20 65 78 69 74 0a 65 78 69 74 |too:~$ exit.exit|
00000070 0a 0a 53 63 72 69 70 74 20 64 6f 6e 65 20 6f 6e |..Script done on|
00000080 20 53 75 6e 20 31 39 20 41 70 72 20 32 30 30 39 | Sun 19 Apr 2009|
00000090 20 30 32 3a 30 35 3a 33 35 20 41 4d 20 45 44 54 | 02:05:35 AM EDT|
000000a0 0a |.|
000000a1


You can see the file is shorter, and lots of characters are gone.

script-declutter is a Perl script. Here's what it looks like.

#!/usr/bin/perl -wp

# clean up control characters and other non-text detritus that shows up
# when you run the "script" command.

BEGIN {
# xterm titlebar escape sequence
$xtermesc = "\x1b\x5d\x30\x3b";

# the occurence of a backspace event (e.g. cntrl H, cntrol W, or cntrl U)
$backspaceevent = "\x1b\\\x5b\x4b"; # note escaping of third character

# ANSI color escape sequence
$ansiesc = qr/\x1b\[[\d;]*?m/;

# technically, this is arrow-right. For some reason, being used against
# very long backspace jobs. I don't fully understand this, as evidenced
# by the fact that is off by one sometimes.
$bizarrebs = qr/\x1b\[C/;

# used as part of the xterm titlebar mechanism, or when
# a bell sounds, which might happen when you backspace too much.
$bell = "\x07"; # could use \a

$cr = "\x0d"; # could use \r

$backspace = "\x08"; # could use \b
}

s/$xtermesc.+?$bell//g;
s/[$cr$bell]//g;
s/${backspaceevent}//g;
s/$ansiesc//g;
while (s/(.)(?=$backspace)//) { s/$backspace//; } # frickin' sweet
# For every ^H delete the character immediately left of it, then delete the ^H.
# Perl's RE's aren't R, so I wonder if I could do this in one expression.
while (s/(..)(?=$bizarrebs)//) { s/$bizarrebs//; }

# notes
# ^[[7P has been spotted. Based on http://www.google.com/codesearch/p?hl=en#4qbG402gtc0/myScreen.C&q="[7P" it appears to be a numbered cursor jump, moving 7 characters (not sure if left or right).


The -w flag, passed to Perl in the first line, turns on some better syntax checking. The -p tells Perl to read in each line of standard input, run the entire script on the line, the print the now transformed input line.

The script then has a BEGIN { ... } section. This section gets run at startup, but doesn't get run for each line of input. The content of the BEGIN section sets up some variables which will get used in regular expressions in the main part of the script. Specifically, it creates patterns to match the xterm titlebar escape sequence, some control characters that show up when certain keyboard events (like when control-H, control-W, or control-U get pressed) occur, ANSI color escape sequences, some strange backspace pattern that I've seen but which I don't understand, and finally the bell, carriage return, and backspace control characters.

I figured out the hex value for these characters using hexdump. You'll see in the comments that some of the control characters, like carriage return, could have been matched using a couple of characters, like "\r". These are C-style or printf-style special format characters. See printf for a complete list. Not every control & escape character has a special format character, so for consistency I didn't use them in the script. They are in the comments as cross-reference.

Most of the control characters and escape sequences are simply deleted. The fact that the bell control character is also part of the titlebar escape sequence isn't a problem as long as they're dealt with in the right order. But both the regular and strange backspace control characters are handled in what I think is a very clever manner. Here's the relevant line:

while (s/(.)(?=$backspace)//) { s/$backspace//; }


This makes egregious use of C-style side effects, and makes no apologies for it. Obviously, it's a while loop. The test portion is actually a substitution. It says "replace the first character in the current input line that is followed by a backspace control character with nothing". The body of the while loop says "replace the first backspace control character with nothing". Because everytime the test portion performs its substitution it also returns true, the while loop will continue looping until there are no more backspace characters. BTW, I realize now that this should work:

while (s/(.$backspace)//) { 1; }


I like the looks of my first version better, although I suspect that it's less efficient. The other backspace handler works the same way, except that it deletes two regular characters for every occurrence of the backspace pattern, and the patter itself is three characters long rather than only one. I've only seen this is happen occasionally. As I've mentioned, I don't understand what this strange backspace variation means, and I seem to recall that it sometimes doesn't line up right, so some control characters or should-be-deleted regular characters get left behind.

The final comment also illustrates that script-declutter isn't perfect (because my understanding of script and control characters isn't perfect).

Another good example of when a script needs decluttering is when you run the GNU ls command in a typsecript. Depending on how it's configured to work by default, or what command line options you give it, or what environmental variables are set, ls will color the names of files according to what kind of file (regular, directory, block, character, symlink), and according to the file's extension (.zip, .midi, .deb, .txt, etc). (See also the dircolors command for more info.) ls uses ANSI escape sequences to set colors, which the script command will capture, and script-declutter will remove, like so:


jdimpson@artoo:~/foo$ script
Script started, file is typescript
jdimpson@artoo:~/foo$ ls -l
total 496
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 bar.zip
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 baz.deb
prw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 fifo
drwxr-xr-x 2 jdimpson jdimpson 4096 2009-04-19 11:20 foo
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 foo.txt
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 typescript
-rw-r--r-- 1 jdimpson jdimpson 496183 2009-04-19 11:21 warty-final-ubuntu.png
jdimpson@artoo:~/foo$ exit
exit
Script done, file is typescript
jdimpson@artoo:~/foo$ cat typescript
Script started on Sun 19 Apr 2009 11:21:47 AM EDT
jdimpson@artoo:~/foo$ ls -l
total 496
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 bar.zip
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 baz.deb
prw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 fifo
drwxr-xr-x 2 jdimpson jdimpson 4096 2009-04-19 11:20 foo
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 foo.txt
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 typescript
-rw-r--r-- 1 jdimpson jdimpson 496183 2009-04-19 11:21 warty-final-ubuntu.png
jdimpson@artoo:~/foo$ exit
exit

Script done on Sun 19 Apr 2009 11:21:51 AM EDT
jdimpson@artoo:~/foo$


The colors don't get picked up when I copy & paste, so here's a screenshot of the directory listing so you can see the colors.



But "vim typesecript" shows this:

Script started on Sun 19 Apr 2009 11:25:08 AM EDT
^[]0;jdimpson@artoo: ~/foo^Gjdimpson@artoo:~/foo$ exit^H^H^H^H^[[Kexit^H^H^H^Hls -l^M
^[[00mtotal 496^M
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 ^[[01;31mbar.zip^[[00m^M
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 ^[[01;31mbaz.deb^[[00m^M
prw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 ^[[40;33mfifo^[[00m^M
drwxr-xr-x 2 jdimpson jdimpson 4096 2009-04-19 11:20 ^[[01;34mfoo^[[00m^M
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 ^[[00mfoo.txt^[[00m^M
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:25 ^[[00mtypescript^[[00m^M
-rw-r--r-- 1 jdimpson jdimpson 496183 2009-04-19 11:21 ^[[01;35mwarty-final-ubuntu.png^[[00m^M
^[[m^[]0;jdimpson@artoo: ~/foo^Gjdimpson@artoo:~/foo$ exit^M
exit^M

Script done on Sun 19 Apr 2009 11:25:15 AM EDT


The special characters before and after the file names are the ANSI color escape sequences. Note also the second line of the script has the string "exit" followed by a bunch of ^H's. That's from me using bash's command line history--rather than typing "ls -l", I hit up-arrow twice to find ls -l in the history.

Here's the hexdump -C:

jdimpson@artoo:~/foo$ hexdump -C typescript
00000000 53 63 72 69 70 74 20 73 74 61 72 74 65 64 20 6f |Script started o|
00000010 6e 20 53 75 6e 20 31 39 20 41 70 72 20 32 30 30 |n Sun 19 Apr 200|
00000020 39 20 31 31 3a 32 35 3a 30 38 20 41 4d 20 45 44 |9 11:25:08 AM ED|
00000030 54 0a 1b 5d 30 3b 6a 64 69 6d 70 73 6f 6e 40 61 |T..]0;jdimpson@a|
00000040 72 74 6f 6f 3a 20 7e 2f 66 6f 6f 07 6a 64 69 6d |rtoo: ~/foo.jdim|
00000050 70 73 6f 6e 40 61 72 74 6f 6f 3a 7e 2f 66 6f 6f |pson@artoo:~/foo|
00000060 24 20 65 78 69 74 08 08 08 08 1b 5b 4b 65 78 69 |$ exit.....[Kexi|
00000070 74 08 08 08 08 6c 73 20 2d 6c 0d 0a 1b 5b 30 30 |t....ls -l...[00|
00000080 6d 74 6f 74 61 6c 20 34 39 36 0d 0a 2d 72 77 2d |mtotal 496..-rw-|
00000090 72 2d 2d 72 2d 2d 20 31 20 6a 64 69 6d 70 73 6f |r--r-- 1 jdimpso|
000000a0 6e 20 6a 64 69 6d 70 73 6f 6e 20 20 20 20 20 20 |n jdimpson |
000000b0 30 20 32 30 30 39 2d 30 34 2d 31 39 20 31 31 3a |0 2009-04-19 11:|
000000c0 32 31 20 1b 5b 30 31 3b 33 31 6d 62 61 72 2e 7a |21 .[01;31mbar.z|
000000d0 69 70 1b 5b 30 30 6d 0d 0a 2d 72 77 2d 72 2d 2d |ip.[00m..-rw-r--|
000000e0 72 2d 2d 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a |r-- 1 jdimpson j|
000000f0 64 69 6d 70 73 6f 6e 20 20 20 20 20 20 30 20 32 |dimpson 0 2|
00000100 30 30 39 2d 30 34 2d 31 39 20 31 31 3a 32 31 20 |009-04-19 11:21 |
00000110 1b 5b 30 31 3b 33 31 6d 62 61 7a 2e 64 65 62 1b |.[01;31mbaz.deb.|
00000120 5b 30 30 6d 0d 0a 70 72 77 2d 72 2d 2d 72 2d 2d |[00m..prw-r--r--|
00000130 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a 64 69 6d | 1 jdimpson jdim|
00000140 70 73 6f 6e 20 20 20 20 20 20 30 20 32 30 30 39 |pson 0 2009|
00000150 2d 30 34 2d 31 39 20 31 31 3a 32 30 20 1b 5b 34 |-04-19 11:20 .[4|
00000160 30 3b 33 33 6d 66 69 66 6f 1b 5b 30 30 6d 0d 0a |0;33mfifo.[00m..|
00000170 64 72 77 78 72 2d 78 72 2d 78 20 32 20 6a 64 69 |drwxr-xr-x 2 jdi|
00000180 6d 70 73 6f 6e 20 6a 64 69 6d 70 73 6f 6e 20 20 |mpson jdimpson |
00000190 20 34 30 39 36 20 32 30 30 39 2d 30 34 2d 31 39 | 4096 2009-04-19|
000001a0 20 31 31 3a 32 30 20 1b 5b 30 31 3b 33 34 6d 66 | 11:20 .[01;34mf|
000001b0 6f 6f 1b 5b 30 30 6d 0d 0a 2d 72 77 2d 72 2d 2d |oo.[00m..-rw-r--|
000001c0 72 2d 2d 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a |r-- 1 jdimpson j|
000001d0 64 69 6d 70 73 6f 6e 20 20 20 20 20 20 30 20 32 |dimpson 0 2|
000001e0 30 30 39 2d 30 34 2d 31 39 20 31 31 3a 32 30 20 |009-04-19 11:20 |
000001f0 1b 5b 30 30 6d 66 6f 6f 2e 74 78 74 1b 5b 30 30 |.[00mfoo.txt.[00|
00000200 6d 0d 0a 2d 72 77 2d 72 2d 2d 72 2d 2d 20 31 20 |m..-rw-r--r-- 1 |
00000210 6a 64 69 6d 70 73 6f 6e 20 6a 64 69 6d 70 73 6f |jdimpson jdimpso|
00000220 6e 20 20 20 20 20 20 30 20 32 30 30 39 2d 30 34 |n 0 2009-04|
00000230 2d 31 39 20 31 31 3a 32 35 20 1b 5b 30 30 6d 74 |-19 11:25 .[00mt|
00000240 79 70 65 73 63 72 69 70 74 1b 5b 30 30 6d 0d 0a |ypescript.[00m..|
00000250 2d 72 77 2d 72 2d 2d 72 2d 2d 20 31 20 6a 64 69 |-rw-r--r-- 1 jdi|
00000260 6d 70 73 6f 6e 20 6a 64 69 6d 70 73 6f 6e 20 34 |mpson jdimpson 4|
00000270 39 36 31 38 33 20 32 30 30 39 2d 30 34 2d 31 39 |96183 2009-04-19|
00000280 20 31 31 3a 32 31 20 1b 5b 30 31 3b 33 35 6d 77 | 11:21 .[01;35mw|
00000290 61 72 74 79 2d 66 69 6e 61 6c 2d 75 62 75 6e 74 |arty-final-ubunt|
000002a0 75 2e 70 6e 67 1b 5b 30 30 6d 0d 0a 1b 5b 6d 1b |u.png.[00m...[m.|
000002b0 5d 30 3b 6a 64 69 6d 70 73 6f 6e 40 61 72 74 6f |]0;jdimpson@arto|
000002c0 6f 3a 20 7e 2f 66 6f 6f 07 6a 64 69 6d 70 73 6f |o: ~/foo.jdimpso|
000002d0 6e 40 61 72 74 6f 6f 3a 7e 2f 66 6f 6f 24 20 65 |n@artoo:~/foo$ e|
000002e0 78 69 74 0d 0a 65 78 69 74 0d 0a 0a 53 63 72 69 |xit..exit...Scri|
000002f0 70 74 20 64 6f 6e 65 20 6f 6e 20 53 75 6e 20 31 |pt done on Sun 1|
00000300 39 20 41 70 72 20 32 30 30 39 20 31 31 3a 32 35 |9 Apr 2009 11:25|
00000310 3a 31 35 20 41 4d 20 45 44 54 0a |:15 AM EDT.|


Now, after running "script-declutter typescript > out":

jdimpson@artoo:~/foo$ script-declutter typescript > out
jdimpson@artoo:~/foo$ cat out
Script started on Sun 19 Apr 2009 11:25:08 AM EDT
jdimpson@artoo:~/foo$ ls -l
total 496
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 bar.zip
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:21 baz.deb
prw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 fifo
drwxr-xr-x 2 jdimpson jdimpson 4096 2009-04-19 11:20 foo
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:20 foo.txt
-rw-r--r-- 1 jdimpson jdimpson 0 2009-04-19 11:25 typescript
-rw-r--r-- 1 jdimpson jdimpson 496183 2009-04-19 11:21 warty-final-ubuntu.png
jdimpson@artoo:~/foo$ exit
exit

Script done on Sun 19 Apr 2009 11:25:15 AM EDT
jdimpson@artoo:~/foo$ hexdump -C out
00000000 53 63 72 69 70 74 20 73 74 61 72 74 65 64 20 6f |Script started o|
00000010 6e 20 53 75 6e 20 31 39 20 41 70 72 20 32 30 30 |n Sun 19 Apr 200|
00000020 39 20 31 31 3a 32 35 3a 30 38 20 41 4d 20 45 44 |9 11:25:08 AM ED|
00000030 54 0a 6a 64 69 6d 70 73 6f 6e 40 61 72 74 6f 6f |T.jdimpson@artoo|
00000040 3a 7e 2f 66 6f 6f 24 20 6c 73 20 2d 6c 0a 74 6f |:~/foo$ ls -l.to|
00000050 74 61 6c 20 34 39 36 0a 2d 72 77 2d 72 2d 2d 72 |tal 496.-rw-r--r|
00000060 2d 2d 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a 64 |-- 1 jdimpson jd|
00000070 69 6d 70 73 6f 6e 20 20 20 20 20 20 30 20 32 30 |impson 0 20|
00000080 30 39 2d 30 34 2d 31 39 20 31 31 3a 32 31 20 62 |09-04-19 11:21 b|
00000090 61 72 2e 7a 69 70 0a 2d 72 77 2d 72 2d 2d 72 2d |ar.zip.-rw-r--r-|
000000a0 2d 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a 64 69 |- 1 jdimpson jdi|
000000b0 6d 70 73 6f 6e 20 20 20 20 20 20 30 20 32 30 30 |mpson 0 200|
000000c0 39 2d 30 34 2d 31 39 20 31 31 3a 32 31 20 62 61 |9-04-19 11:21 ba|
000000d0 7a 2e 64 65 62 0a 70 72 77 2d 72 2d 2d 72 2d 2d |z.deb.prw-r--r--|
000000e0 20 31 20 6a 64 69 6d 70 73 6f 6e 20 6a 64 69 6d | 1 jdimpson jdim|
000000f0 70 73 6f 6e 20 20 20 20 20 20 30 20 32 30 30 39 |pson 0 2009|
00000100 2d 30 34 2d 31 39 20 31 31 3a 32 30 20 66 69 66 |-04-19 11:20 fif|
00000110 6f 0a 64 72 77 78 72 2d 78 72 2d 78 20 32 20 6a |o.drwxr-xr-x 2 j|
00000120 64 69 6d 70 73 6f 6e 20 6a 64 69 6d 70 73 6f 6e |dimpson jdimpson|
00000130 20 20 20 34 30 39 36 20 32 30 30 39 2d 30 34 2d | 4096 2009-04-|
00000140 31 39 20 31 31 3a 32 30 20 66 6f 6f 0a 2d 72 77 |19 11:20 foo.-rw|
00000150 2d 72 2d 2d 72 2d 2d 20 31 20 6a 64 69 6d 70 73 |-r--r-- 1 jdimps|
00000160 6f 6e 20 6a 64 69 6d 70 73 6f 6e 20 20 20 20 20 |on jdimpson |
00000170 20 30 20 32 30 30 39 2d 30 34 2d 31 39 20 31 31 | 0 2009-04-19 11|
00000180 3a 32 30 20 66 6f 6f 2e 74 78 74 0a 2d 72 77 2d |:20 foo.txt.-rw-|
00000190 72 2d 2d 72 2d 2d 20 31 20 6a 64 69 6d 70 73 6f |r--r-- 1 jdimpso|
000001a0 6e 20 6a 64 69 6d 70 73 6f 6e 20 20 20 20 20 20 |n jdimpson |
000001b0 30 20 32 30 30 39 2d 30 34 2d 31 39 20 31 31 3a |0 2009-04-19 11:|
000001c0 32 35 20 74 79 70 65 73 63 72 69 70 74 0a 2d 72 |25 typescript.-r|
000001d0 77 2d 72 2d 2d 72 2d 2d 20 31 20 6a 64 69 6d 70 |w-r--r-- 1 jdimp|
000001e0 73 6f 6e 20 6a 64 69 6d 70 73 6f 6e 20 34 39 36 |son jdimpson 496|
000001f0 31 38 33 20 32 30 30 39 2d 30 34 2d 31 39 20 31 |183 2009-04-19 1|
00000200 31 3a 32 31 20 77 61 72 74 79 2d 66 69 6e 61 6c |1:21 warty-final|
00000210 2d 75 62 75 6e 74 75 2e 70 6e 67 0a 6a 64 69 6d |-ubuntu.png.jdim|
00000220 70 73 6f 6e 40 61 72 74 6f 6f 3a 7e 2f 66 6f 6f |pson@artoo:~/foo|
00000230 24 20 65 78 69 74 0a 65 78 69 74 0a 0a 53 63 72 |$ exit.exit..Scr|
00000240 69 70 74 20 64 6f 6e 65 20 6f 6e 20 53 75 6e 20 |ipt done on Sun |
00000250 31 39 20 41 70 72 20 32 30 30 39 20 31 31 3a 32 |19 Apr 2009 11:2|
00000260 35 3a 31 35 20 41 4d 20 45 44 54 0a |5:15 AM EDT.|
0000026c


All the control and escape characters are gone.