• Documentation ◇ on how to do a specific thing • Proof ◇ that you've done something • Troubleshooting ◇ capture a hard-to-replicate issue, record hard-to-produce issues
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Record
syntax: script [filename] script # start recording # do some stuff echo “Done” exit# end recording # or ctrl-d
• By default, script command output is saved in file ‘typescript’
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Examine ‘script’ Output
less typescript # contains special characters, LF etc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Real-time Recordings
# Add timing information, so you can replay the shell session later script myscript.log --timing=time.log #or script myscript.log -t time.log
# do some stuff ctrl-d ls myscript.log # contains more special characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replay a script log
# Replaying a script won't actually perform the same actions again scriptreplay -s=myscript.log --timing=time.log # or scriptreplay -s=myscript.log -t time.log
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Log a Single Command
script -c 'netstat -tupln' netstat.log less netstat.log