FAQ
Hi to all,
I 'm writing a linux console app with sockets. It's basically a client
app that fires commands in a server.
For example:
$log user 55
$sessions list
$server list etc.
What i want is, after entering some commands, to press the up arrow
key and see the previous commands that i have executed.
Any hints? Any examples?

Antonis

Search Discussions

  • Benjamin Kaplan at Jul 20, 2010 at 9:47 pm

    On Tue, Jul 20, 2010 at 2:38 PM, kaklis at gmail.com wrote:
    Hi to all,
    I 'm writing a linux console app with sockets. It's basically a client
    app that fires commands in a server.
    For example:
    $log user 55
    $sessions list
    $server list etc.
    What i want is, after entering some commands, to press the up arrow
    key and see the previous commands that i have executed.
    Any hints? Any examples?

    Antonis
    --
    Look at the readline module.
    http://docs.python.org/library/readline.html
  • Kaklis at Jul 20, 2010 at 11:12 pm

    On Jul 21, 12:47?am, Benjamin Kaplan wrote:
    On Tue, Jul 20, 2010 at 2:38 PM, kak... at gmail.com wrote:
    Hi to all,
    I 'm writing a linux console app with sockets. It's basically a client
    app that fires commands in a server.
    For example:
    $log user 55
    $sessions list
    $server list etc.
    What i want is, after entering some commands, to press the up arrow
    key and see the previous commands that i have executed.
    Any hints? Any examples?
    Antonis
    --
    Look at the readline module.http://docs.python.org/library/readline.html
    ok that's fine, thanks.
    I have also find a very helpful example in PyMoTW
    http://www.doughellmann.com/PyMOTW/readline/index.html(Thanks
    Doug!!!).
    But if i want to run this in it's own separate thread, how could i do
    that?
    there is an
    # Prompt the user for text
    input_loop()

    which is blocking?



    Antonis K.
  • Michele Simionato at Jul 21, 2010 at 6:03 am

    On Jul 20, 11:38?pm, "kak... at gmail.com" wrote:
    Hi to all,
    I 'm writing a linux console app with sockets. It's basically a client
    app that fires commands in a server.
    For example:
    $log user 55
    $sessions list
    $server list etc.
    What i want is, after entering some commands, to press the up arrow
    key and see the previous commands that i have executed.
    Any hints? Any examples?

    Antonis
    You may find interesting to look at the source code for plac (http://
    micheles.googlecode.com/hg/plac/doc/plac_adv.html). The readline
    support (including command history and autocompletion) is implemented
    in the ReadlineInput class (see http://code.google.com/p/micheles/source/browse/plac/plac_ext.py).
    If you just want command history you can use rlwrap (http://
    freshmeat.net/projects/rlwrap).
  • Kaklis at Jul 21, 2010 at 8:03 am

    On Jul 21, 9:03?am, Michele Simionato wrote:
    On Jul 20, 11:38?pm, "kak... at gmail.com" wrote:

    Hi to all,
    I 'm writing a linux console app with sockets. It's basically a client
    app that fires commands in a server.
    For example:
    $log user 55
    $sessions list
    $server list etc.
    What i want is, after entering some commands, to press the up arrow
    key and see the previous commands that i have executed.
    Any hints? Any examples?
    Antonis
    You may find interesting to look at the source code for plac (http://
    micheles.googlecode.com/hg/plac/doc/plac_adv.html). The readline
    support (including command history and autocompletion) is implemented
    in the ReadlineInput class (seehttp://code.google.com/p/micheles/source/browse/plac/plac_ext.py).
    If you just want command history you can use rlwrap (http://
    freshmeat.net/projects/rlwrap).
    That's great! thank you so much Michele!

    Antonis

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 20, '10 at 9:38p
activeJul 21, '10 at 8:03a
posts5
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase