Python equivalent of script(1)

Discussion in 'Python' started by cepl, Jan 1, 2005.

  1. cepl

    cepl Guest

    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
     
    cepl, Jan 1, 2005
    #1
    1. Advertisements

  2. cepl

    Thomas Rast Guest

    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
     
    Thomas Rast, Jan 1, 2005
    #2
    1. Advertisements

  3. cepl

    cepl Guest

    Thanks a lot.
     
    cepl, Jan 1, 2005
    #3
  4. $ script transcript.txt
    Script started, file is transcript.txt
    $ python
    ...

    Not sure if there's a way to shut off readline...
     
    Grant Edwards, Jan 1, 2005
    #4
  5. cepl

    Mike Meyer Guest

    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
     
    Mike Meyer, Jan 1, 2005
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.