3 # script.py -- Make typescript of terminal session.
5 # -a Append to typescript.
6 # -p Use Python as shell.
7 # Author: Steen Lumholt.
10 import os
, time
, sys
, getopt
14 data
= os
.read(fd
, 1024)
19 filename
= 'typescript'
21 if os
.environ
.has_key('SHELL'):
22 shell
= os
.environ
['SHELL']
25 opts
, args
= getopt
.getopt(sys
.argv
[1:], 'ap')
26 except getopt
.error
, msg
:
27 print '%s: %s' % (sys
.argv
[0], msg
)
36 script
= open(filename
, mode
)
38 sys
.stdout
.write('Script started, file is %s\n' % filename
)
39 script
.write('Script started on %s\n' % time
.ctime(time
.time()))
40 pty
.spawn(shell
, read
)
41 script
.write('Script done on %s\n' % time
.ctime(time
.time()))
42 sys
.stdout
.write('Script done, file is %s\n' % filename
)