On Aug 19, 2007, at 8:58 PM, [EMAIL PROTECTED] wrote:

> I am trying to run the following script:
>
>
> #!/usr/bin/python
>
> import popen2
>
> commandToRun = """scp scp_trial.py [EMAIL PROTECTED]:/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 [EMAIL PROTECTED]:/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

---
The Rules of Optimization are simple.
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.
                                  -Michael A. Jackson


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to