calling python scripts as a sub-process
jeremy+complangpython at jeremysanders.net
Wed Nov 19 22:40:05 CET 2008
Catherine Moroney wrote:
> I have one script (Match1) that calls a Fortran executable as a
> sub-process, and I want to write another script (Match4) that
> spawns off several instances of Match1 in parallel and then waits
> until they all finish running. The only way I can think of doing this
> is to call it as a sub-process, rather than directly.
> I'm able to get Match1 working correctly in isolation, using the
> subprocess.Popen command, but calling an instance of Match1 as a
> subprocess spawned from Match4 isn't working.
> The command (stored as an array of strings) that I'm executing is:
> ['python ../src_python/Match1.py ',
> '--file_ref=MISR_AM1_GRP_ELLIPSOID_GM_P228_O003571_BF_F03_0024.hdf ',
> '--file_cmp=MISR_AM1_GRP_ELLIPSOID_GM_P228_O003571_DF_F03_0024.hdf ',
> '--block_start=62 ', '--block_end=62 ', '--istep=16 ', "--chmetric='M2'
> ", "--use_textid='true '"]
If you want to avoid going by the shell, and you *should* for security
reasons, you need to have each of your arguments separately in the list
without the shell quoting and extra spaces, i.e.
'--block_start=xx', '--block_end=62', '--istep=16', '--chmetric=M2',
More information about the Python-list