[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.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list