[Tutor] Correct way to call an outside program?
pylinuxian at gmail.com
Thu Mar 13 13:31:32 CET 2008
simplest way to run external commands !
cmd="/usr/bin/ssh 10.0.0.20 uptime"
my cmd is just an example, use any cmd you want & its output will be
displayed to you.
hope this helps
On Thu, Mar 13, 2008 at 12:05 PM, Kent Johnson <kent37 at tds.net> wrote:
> Allen Fowler wrote:
> > Hello,
> > I need to call an external command line .exe utility from my Python
> > What is the best way to capture the output (if any) and (optionally)
> direct it to my normal standard output?
> subprocess.Popen().communicate() will do it:
> In : import subprocess
> In : x=subprocess.Popen('ls', stdout=subprocess.PIPE,
> In : print x
> If you just want stdout and stderr of the subprocess to go to stdout and
> stderr of the calling process you can omit those arguments to Popen().
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor