Python equivalent of script(1)

C

cepl

Is there anything like script(1) for python interactive sessions. From
script(1) 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.

In my case I wouldn't like to use it as a proof of anything, but I want
to get a script accessing a library system in my school -- it means
many attempts to play with urllib. I would prefer to do it in an
interactive session, but then I would love to have a record of all what
I've done, so I can edit this record into final script.
Thanks for any hint,

Matej Cepl
 
T

Thomas Rast

I would love to have a record of all what I've done, so I can edit
this record into final script.

You can save the current input history with

If you want to log your whole session, including output, try using the
'screen' utility.

HTH
- Thomas
 
G

Grant Edwards

Is there anything like script(1) for python interactive sessions.

$ script transcript.txt
Script started, file is transcript.txt
$ python
...

Not sure if there's a way to shut off readline...
 
M

Mike Meyer

In my case I wouldn't like to use it as a proof of anything, but I want
to get a script accessing a library system in my school -- it means
many attempts to play with urllib. I would prefer to do it in an
interactive session, but then I would love to have a record of all what
I've done, so I can edit this record into final script.
Thanks for any hint,

Emacs will do that for you, either in a shell (command shell) or in a
Python shell. Edit a python file, and type C-C ! and it'll start an
interactive python in a buffer that will save all the output.

Of course, you can also run your python after running script. That
will log everything from the python session in the script file.

<mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top