Catching console output interactively

Discussion in 'Python' started by Byrom, R (Rob), Apr 16, 2004.

  1. hi,

    I'd like to be able to trap console output as the user writes interactively.
    For example if the user press the up or down keys I'd like to be able to
    catch this and return the last executed command (a bit like the bash_history
    idea). Can anyone point me in the right direction?

    thanks for any help,

    Rob
    Byrom, R (Rob), Apr 16, 2004
    #1
    1. Advertising

  2. Byrom, R (Rob)

    Jarek Zgoda Guest

    Dnia Fri, 16 Apr 2004 13:56:24 +0100, Byrom, R (Rob) pisze:

    > I'd like to be able to trap console output as the user writes
    > interactively. For example if the user press the up or down keys I'd
    > like to be able to catch this and return the last executed command (a
    > bit like the bash_history idea). Can anyone point me in the right
    > direction?


    This is feature of GNU readline library, available on some Unix and
    Unix-like systems. If you want to build something, that resembles Unix
    shells, you can use class Cmd from cmd module. This class uses readline if
    it is available on host system. I don't know, how it behaves on Windows
    and if it uses capabilities of cmd.exe.

    --
    Jarek Zgoda
    http://jpa.berlios.de/
    Jarek Zgoda, Apr 18, 2004
    #2
    1. Advertising

  3. Byrom, R (Rob)

    Miki Tebeka Guest

    Hello Rob,

    > I'd like to be able to trap console output as the user writes interactively.
    > For example if the user press the up or down keys I'd like to be able to
    > catch this and return the last executed command (a bit like the bash_history
    > idea). Can anyone point me in the right direction?

    Depending on what you'd like to do you can try:
    "curses" module (available only on unix like systems)
    wxPython
    PyGame

    HTH.
    Miki
    Miki Tebeka, Apr 18, 2004
    #3
  4. Byrom, R (Rob)

    Miki Tebeka Guest

    Hello Rob,

    > I'd like to be able to trap console output as the user writes interactively.
    > For example if the user press the up or down keys I'd like to be able to
    > catch this and return the last executed command (a bit like the bash_history
    > idea). Can anyone point me in the right direction?

    Depending on what you'd like to do you can try:
    "curses" module (available only on unix like systems)
    wxPython
    PyGame

    HTH.
    Miki
    Miki Tebeka, Apr 18, 2004
    #4
  5. "Byrom, R (Rob) " <> writes:

    > hi,
    >
    > I'd like to be able to trap console output as the user writes interactively.
    > For example if the user press the up or down keys I'd like to be able to
    > catch this and return the last executed command (a bit like the bash_history
    > idea). Can anyone point me in the right direction?


    What platform?

    Cheers,
    mwh

    --
    There's an aura of unholy black magic about CLISP. It works, but
    I have no idea how it does it. I suspect there's a goat involved
    somewhere. -- Johann Hibschman, comp.lang.scheme
    Michael Hudson, Apr 20, 2004
    #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. IchBin
    Replies:
    3
    Views:
    1,271
    IchBin
    Mar 2, 2005
  2. Peter A. Schott
    Replies:
    3
    Views:
    257
    Kent Johnson
    Dec 10, 2005
  3. pratap
    Replies:
    3
    Views:
    444
    James Kanze
    Jul 19, 2007
  4. Replies:
    5
    Views:
    3,415
    James Kanze
    Mar 4, 2008
  5. terminus
    Replies:
    0
    Views:
    409
    terminus
    Feb 26, 2008
Loading...

Share This Page