fork/exec with input redirection

Erik Jones erik at myemma.com
Mon Nov 26 17:19:14 EST 2007


On Nov 26, 2007, at 3:58 PM, Dan Upton wrote:

> I have a Python script that does a fork/exec, so the parent process
> can get the child's PID and monitor /proc/PID/stat (on a CentOS
> system).  Most of my processes' command lines are straightforward
> enough to do this with, but I have a handful that use < on the command
> line, eg
>
> ./gobmk_base.linux_x86 --quiet --mode gtp < 13x13.tst
>
> The only thing I could really think of to try was
>
>    os.execv("./gobmk_base.linux_x86", ["./gobmk_base.linux_x86",
> "--quiet", "--mode", "gtp", "<", "13x13.tst"])
>
> but this apparently doesn't work.  Is there some other way to
> accomplish what I'm going for?

Read up on the docs for the subprocess module.

Erik Jones

Software Developer | Emma®
erik at myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com





More information about the Python-list mailing list