Python equivalent of script(1)

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

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

  2. Thomas Rast Guest

    writes:

    > 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

    >>> import readline
    >>> readline.write_history_file("python.log")


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

    HTH
    - Thomas

    --
    If you want to reply by mail, substitute my first and last name for
    'foo' and 'bar', respectively, and remove '.invalid'.
     
    Thomas Rast, Jan 1, 2005
    #2
    1. Advertising

  3. Guest

    Thanks a lot.
     
    , Jan 1, 2005
    #3
  4. On 2005-01-01, <> wrote:

    > 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...

    --
    Grant Edwards grante Yow! But was he mature
    at enough last night at the
    visi.com lesbian masquerade?
     
    Grant Edwards, Jan 1, 2005
    #4
  5. Mike Meyer Guest

    writes:

    > 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
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Jan 1, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sarmin kho
    Replies:
    1
    Views:
    377
    Cameron Laird
    Jun 4, 2004
  2. Replies:
    3
    Views:
    1,058
    James Stroud
    Dec 13, 2005
  3. johnny
    Replies:
    5
    Views:
    515
    Antonio Cuni
    Jul 11, 2007
  4. Rajat
    Replies:
    3
    Views:
    702
    Jorgen Grahn
    Jan 8, 2010
  5. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    564
    Jan Kaliszewski
    Jan 7, 2010
Loading...

Share This Page