passing arguments from a python program to other while executing it with exec() or spawn() in LINUX

Peter Otten __peter__ at
Thu Oct 16 09:57:25 CEST 2008

gaurav kashyap wrote:

> HI all,
> i have two python programs as and
> import os
> import sys
> processID=os.spawnl(os.P_WAIT,'/usr/local/bin/python','python','/
> mywork/ ' + 'hi')
> import sys
> domain= str(sys.argv[1] )
> print domain
> while executing,the argument 'hi' is not passed to the and
> error message is displayed as :
> python: can't open file '/mywork/'.

Did you cut and paste that? I would expect the message to be 

python: can't open file '/mywork/ hi'.

or similar, i. e. the script name is assumed to be '/mywork/ hi'. You
have to pass arguments to the script as separate arguments to

os.spawnl(os.P_WAIT,'/usr/local/bin/python','python','/mywork/', 'hi')


More information about the Python-list mailing list