popen4

B

billie

Hi all. I'm trying to execute system commands and capture the output by
using popen4:

stdout example:
exec_cmd = popen2.popen4("echo hello!")
output = exec_cmd[0].read()
hello

stderr example:
exec_cmd = popen2.popen4("echobv hello!")
output = exec_cmd[0].read()
Unrecognized command

The problem occurs when I try to execute interactive commands like ftp,
python intepreter etc...
In this case the program crashes without even giving an error.
Suggestions?

Regards
 
P

Piet van Oostrum

billie said:
b> Hi all. I'm trying to execute system commands and capture the output by
b> using popen4:
b> stdout example:
exec_cmd = popen2.popen4("echo hello!")
output = exec_cmd[0].read()
b> hello
b> stderr example:
exec_cmd = popen2.popen4("echobv hello!")
output = exec_cmd[0].read()
b> Unrecognized command
b> The problem occurs when I try to execute interactive commands like ftp,
b> python intepreter etc...
b> In this case the program crashes without even giving an error.
Crashes?

b> Suggestions?

I think you need something like pyexpect for this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top