os.spawnv & stdin trouble

Denis S. Otkidach ods at strana.ru
Wed Jan 12 03:23:43 EST 2005


On Tue, 11 Jan 2005 19:08:01 +0100
"Jelle Feringa // EZCT / Paris" <jelle.feringa at ezct.net> wrote:

> Using the subprocess module, but still not making any real progress...
> I'm trying to make the examples given in the __doc__ work, without any
> success I'm afraid, have you had more luck with it?
[...]
> p = Popen("xform" + " -t 0 8 0 wallo.rad", stdout=PIPE,
> shell=True).communicate()[0]
> p.stdout
> 
> p = Popen("dir" + " /w", stdout=PIPE, shell=True).communicate()[0]
> p.stdout

If you want passing parameters via shell (shell=True), than just use
os.system.  Nevertheless below is correct example of subprocess usage
with stdout redirected to file:

out_fp = open('wall0.TRANS.rad', 'wb')
subprocess.call(['c:\\Radiance\\bin\\xform.exe',
                 '-t', '0', '8', '0', 'wallo.rad'],
                stdout=out_fp)

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]



More information about the Python-list mailing list