popen4 not returning output

H

hortitude

I am trying to run the following script:


#!/usr/bin/python

import popen2

commandToRun = """scp scp_trial.py user@host:/targetDirectory"""
#commandToRun = "ls"
print commandToRun
p_out, p_in = popen2.popen4 (commandToRun)

theOut = p_out.readlines ()
print theOut


When I run this command with the "ls" command I see the output.
When I run this with the scp command I do not see the output of my
command -- however the file is successfully transfered. How can I see
the output?

Thanks
 
J

James Stroud

I am trying to run the following script:


#!/usr/bin/python

import popen2

commandToRun = """scp scp_trial.py user@host:/targetDirectory"""
#commandToRun = "ls"
print commandToRun
p_out, p_in = popen2.popen4 (commandToRun)

theOut = p_out.readlines ()
print theOut


When I run this command with the "ls" command I see the output.
When I run this with the scp command I do not see the output of my
command -- however the file is successfully transfered. How can I see
the output?

Thanks

I'm not up on my scp, but look at popen3 and read from err.

James
 
M

Michael Bentley

I am trying to run the following script:


#!/usr/bin/python

import popen2

commandToRun = """scp scp_trial.py user@host:/targetDirectory"""
#commandToRun = "ls"
print commandToRun
p_out, p_in = popen2.popen4 (commandToRun)

theOut = p_out.readlines ()
print theOut


When I run this command with the "ls" command I see the output.
When I run this with the scp command I do not see the output of my
command -- however the file is successfully transfered. How can I see
the output?

scp will not produce output on stdout or stderr if stdout/stderr is
redirected. I assume it uses an ioctl with TCGETA to determine the
terminal characteristics of the device connected to stdout, and get
either an EINVAL (for a pipe) or ENOTTY (for a file) failure when no
terminal is attached.

You can test whether it works the same on your system by running your
scp from the command line and redirecting the output:

scp scp_trial.py user@host:/targetDirectory >scp.stdout 2>scp.stderr

Both files will exist (the shell does this before starting the scp
command), but will (I think) be empty.

hope this helps,
Michael
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top