How to start a process?

Dave Brueck dbrueck at edgix.com
Tue Dec 12 15:33:43 CET 2000


Hi David,

The exec* routines _replace_ the current process with the new one, so this
doesn't really help you achieve the goal of several simultaneous processes.
See os.fork and the os.spawn* functions.

Anyway, if you use os.execvp you don't have to specify the full path to the
executable- it'll search your $PATH var for it. Also, the first (zero'th)
arg is the name of the program:

os.execvp('python',['python','hack.py','foo','bar'])

-Dave

> Subject: How to start a process?
>
>
> I would like to start up a number of simultaneos processes
> from a Python
> script.  Can someone explain or refer me to a document that explains
> what is going on below.  As a test I am executing a script 'hack.py'.
> Why do I get this OSError when I try using execv, but it runs
> when I use
> 'execfile'?
>
> Thanks in advance.
>
> david lees
>
>
> >>> execfile('hack.py')
> foo to you charlie
> more hacks
> >>> os.execv('e:\python20\hack.py',['foo','bar'])
> Traceback (innermost last):
> File "<interactive input>", line 1, in ?
> OSError: [Errno 8] Exec format error
> >>>
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list