os.popen2 :URGENT
Peter Hansen
peter at engcorp.com
Tue May 27 15:51:02 EDT 2003
Ali Dada wrote:
>
> small but very urgent question (project rpesentation tommorow!!!)
>
> i need to call a command line program from python, but the program prompts for a
> user input ('y' for yes or 'n' for no). how can i write, using python, one of
> those values???
>
> i thought of using something like os.popen('my_program')[1].write('y')
>
> but it didn't work, the program said: received broken pipe signal
If you want to write to the pipe whose file handle is returned by
popen(), you must open it with "w" mode, as documented at
http://www.python.org/doc/2.0/lib/os-newstreams.html
-Peter
More information about the Python-list
mailing list