Interacting With Another Script

lkcl luke.leighton at googlemail.com
Sun Apr 25 13:35:21 EDT 2010


On Mar 11, 2:16 am, alex23 <wuwe... at gmail.com> wrote:
> Victor Subervi <victorsube... at gmail.com> wrote:
> > > There's a program (vpopmail) that has commands which, when called, request
> > > input ("email address", "password", etc.) from the command line. I would
> > > like to build a TTW interface for my clients to use that interacts with
> > > these commands.
>
> The Pexpect[1] module is pretty much aimed at doing exactly this.
>
> 1:http://www.noah.org/wiki/Pexpect

 i also made some patches to telnetlib.py back in 2000, creating an
expectlib.py and then using that in telnetlib.py.  the code is still
in python's bug tracker, and no fucker has integrated it, despite it
still being valid, relevant and useful, in ten years since.

 the code basically creates a base class from which the "old"
telnetlib derives, but it also provides an additional class
TelnetPopen which, as you might expect, can be used to run python
popen and then use _all_ of the functions in telnetlib which should
never have been hard-coded as specifically being associated with the
Telnet class (hence why i moved them to expectlib.py).

 it's therefore possible to use it to do ssh "as if" it was telnet
(remember to use the -t option to stop terminal translation, and
remember to use TelnetPopen because otherwise you have to patch ssh to
accept passwords on the command-line!)

 in order to avoid clashes with telnetlib.py, i often rename it to
telnetlib2.py and i believe i've regularly published them in other
free software projects, so you should find it with a search for
"telnetlib2.py".  if you can't specifically find the two modules, let
me know, and i'll make them available somewhere.

 l.




More information about the Python-list mailing list