Problems with os.spawnv

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Apr 5 17:39:28 EDT 2007


En Thu, 05 Apr 2007 18:19:56 -0300, Henrik Lied <henriklied at gmail.com>  
escribió:

> So, I thought to myself that spawnv would be a good fit for this. The
> problem is that it doesn't fire of the command.
>
> Here's my test script: http://dpaste.com/hold/7981/
>
> Why won't this work? The while-loop is printed, but the os command
> isn't executed. I've also tried to specify the whole path to mencoder
> (/opt/local/bin/mencoder), but to no use.
>

You are using:
     v = os.spawnv(os.P_NOWAIT, "mencoder", "/Users/henriklied/test.mov   
-ofps 25 -o test.flv ...")

Read the docs about the spawnv function:  
http://docs.python.org/lib/os-process.html#l2h-2749

In particular "...The "v" variants are good when the number of parameters  
is variable, with the arguments being passed in a list or tuple as the  
args parameter. In either case, the arguments to the child process must  
start with the name of the command being run."

So, for spawnv, you should build a list with each argument as an item,  
being "mencoder" the first item.
But in your case it's a lot easier to use spawnl:

     v = os.spawnl(os.P_NOWAIT, "mencoder", "mencoder",  
"/Users/henriklied/test.mov", "-ofps", "25", "-o", "...")

-- 
Gabriel Genellina




More information about the Python-list mailing list