[Tutor] Writing a script to interact with an interactive commandprogram
Alan Gauld
alan.gauld at btinternet.com
Tue Jun 10 02:19:17 CEST 2008
"Demonic Software" <demonic.software at gmail.com> wrote
> (cin, cout_cerror) = os.popen4("/bin/bash")
>
> # write a command on the input pipe of the shell
> print "writing ls -all!\n\n"
> cin.write("ls -all")
> cin.flush()
I would have expected that you needed to pass an
explicit newline at the end of the command?
Just a guess.
Also consider using the subprocess module and the Popen class.
os.popen is somewhat deprecated nowadays.
HTH
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list