Output from subprocess.Popen()

Clodoaldo Pinto Neto clodoaldo.pinto at gmail.com
Sun Oct 15 10:47:02 EDT 2006


Output from the shell:

[cpn at s0 teste]$ set | grep IFS
IFS=$' \t\n'

Output from subprocess.Popen():

>>> import subprocess as sub
>>> p = sub.Popen('set | grep IFS', shell=True, stdout=sub.PIPE)
>>> p.stdout.readlines()[1]
"IFS=' \t\n"

Both outputs for comparison:
IFS=$' \t\n'
"IFS=' \t\n"

The subprocess.Popen() output is missing the $ and the last '

How to get the raw shell output from subprocess.Popen()?

Regards, Clodoaldo Pinto Neto




More information about the Python-list mailing list