On Fri, Dec 26, 2008 at 8:09 AM, Emad Nawfal (عماد نوفل)
<emadnaw...@gmail.com> wrote:
> suppose I have an external program that prints "testing the subprocess
> module"
> I know I can run it through the commands module like this:
>
>>>> a = commands.getoutput("python3.0 hello.py")
>>>> a
> 'testing the subprocess module'


> I cannot figure out how to do the same thing in the subprocess module. Can
> somebody please explain how to get the same behaviour from, say,
> subprocess.call

Sometthing like this, I think:

proc = subprocess.Popen('python3.0 hello.py',
                       shell=True,
                       stdout=subprocess.PIPE,
                       )
stdout_value = proc.communicate()[0]

(Courtesy of http://blog.doughellmann.com/2007/07/pymotw-subprocess.html)

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to