Redirecting input?

Jeff Shannon jeff at ccvcorp.com
Tue Jul 3 15:00:57 EDT 2001


fbasegmez wrote:

> How do you redirect commands to a Unix process initiated from a Python script?
> For example:
>
> import os
>
> runcmd='rlogin othersystem'
> os.system(runcmd)
> password='mypassword'
> #now I would like to input my password here
> #obviously os.sytem(password) does not work.
> ???
>
> Regards,
>
> Fahri

You need to look into the os.popen() family of functions.  These
can create a pipe and return file-like objects for stdin, stdout,
and stderr (depending on which flavor of popen you use.)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list