Problem with execv
Jeremy Hylton
jeremy at beopen.com
Thu Jun 29 23:44:31 EDT 2000
sebv at netscape.net writes:
> I'm trying to execute a simple 'ls' command from python, using
> execv but I have a TypeError. I couldn't find any similar
> problem reported somewhere else. Please give me a advice !
> thanks,
>
> Python 1.5.2 (#2, Jun 28 2000, 16:52:22) [GCC 2.8.1] on sunos5
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import os
> >>> os.execv('ls','')
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: illegal argument type for built-in operation
>
The error message will be much clearer in the next Python release!
Python 2.0b1 (#33, Jun 29 2000, 23:26:05) [GCC egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
>>> import os
>>> os.execv('ls', '')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argv must be tuple or list
The correct calling convention is to supply a tuple or list as the
second argument to execv. Example:
>>> os.execv('/bin/ls', ('.',))
[lists contents of current directory]
Jeremy
-- Jeremy Hylton, PythonLabs
http://www.pythonlabs.com/
More information about the Python-list
mailing list