os.spawnv & stdin trouble

Denis S. Otkidach ods at strana.ru
Tue Jan 11 12:05:26 EST 2005


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

> ##I know I should be using 2.4 and os.Popen, I know, I know.
> ##However, since most modules I need, I'm using 2.3 for this script

There is os.popen in 2.3, as well as popen2 module.  Did you mean
subprocess?  I guess it's ported to 2.3 too.

> Here's where I run into trouble.
> In my os.system version, I'm perfectly able to pipe into another file,
> since the process has no real connection to python whatsoever.
> Would someone be able to explain me how to do this, all the tools I'm
> using for this script are unix-like tools and heavily rely on piping.

os.system passes commend to shell, which handles redirect for you
instead of passing '>' to xform.exe as parameter.  Use os.system or
subprocess (a.k.a. popen5).

> program = 'xform.exe'
> path = 'c:\Radiance\bin\'
                         ^^
Syntax error here.  Did you mean 'c:\\Radiance\\bin\\xform.exe'?

> args = ['-t 0 8 0', 'wall0.rad', '>', 'wall0.TRANS.rad']
> os.spawnv(os.P_WAIT, path, ('xform', args))

This corresponds to 
c:\Radiance<BS>in\ '-t 0 8 0' wall0.rad '>' wall0.TRANS.rad'
command line.

> here's the cmd error message:
> xform: cannot find file ">"

Don't understand how you got this error having syntax error and wrong
path to executable.

> ##for your info I'm on win/xp, python 2.3.4

BTW, you are trying to redirect stdout.  Wrong subject?

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



More information about the Python-list mailing list