Subprocess or Process or OMG!!

rh0dium steven.klass at
Fri May 19 00:47:59 CEST 2006

Hi all,

Here I was happily coming to working thinking - OK I need to create a
wrapper for a tool (UNIX) which does nothing but lauch the end tool and
send a sql instert letting the db know the tool was launched (Can we
say Big Brother..).  Some of the tools are very long running with lots
of data others are small and very fast..  So I started down my
traditional approach - Check google groups for the answer.  I quickly
became aware of how challenging this actually is.  See my approach was

Tool name = FOOBAR
Symbolically link FOOBAR to my

1.  Get the args and some other key data (user, cwd, etc)
2.  Fork this process and get FOOBAR running (time is of essense of
3.  On the side submit a mySQL call saying what happened...

Sounds simple and I thought I was ready to go.. Until google groups...

OK so now I need to think about I/O redirection hmmm OK More data..
People have dealt with this - but most of it's dated..

Wait import subprocess..  Looks promising hey some has really used

Needless to say this is much more complex than what I was "hoping" for.
 Has anyone solved this in a generic approach..

    #!/usr/bin/env python

    import os,sys,string
    import subprocess

    argc = len(sys.argv)

    # Yes I move all exe's to the .bin direcotory
    sys.argv[0]=os.path.join(os.getcwd() + "/.bin/" +

    cmd = string.join(sys.argv," ")
    subprocess.Popen( cmd )

This has several problems - least of which args aren't working....  Has
anyone really tried this approach?

More information about the Python-list mailing list