execl difficulty

python newbie mesteve_b at hotmail.com
Mon Dec 15 02:20:36 CET 2003


Since you both agree, I'll try spawn. thanks for the help and the insight.
As Paul Harvey would say, good day ( or evening)
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message
news:mailman.146.1071443928.9307.python-list at python.org...
> "python newbie" wrote:
>
> > Can anyone tell me why this would cause "Invalid Number of Parameters"
while
> > trying to compile (or interpret or whatever)
> >
> > import os
> >
os.execl("C:/WINDOWS/system32/xcopy.exe","E:/MainWeb/dreampics/*.*","E:/Main
> > Web/dp")
> >
> > Here's what the Python reference says:
> >      execl(path,arg0, arg1, ...)
>
> first, fix the slashes.  xcopy wants backward slashes in the filenames,
> not forward slashes.
>
> next, fix the number of arguments.  at the top of the reference page
> you refer to, there's a paragraph explaining how the exec arguments
> work:
>
>     The various exec*() functions take a list of arguments for the
>     new program loaded into the process. In each case, the first
>     of these arguments is passed to the new program as its own
>     name rather than as an argument a user may have typed on
>     a command line. For the C programmer, this is the argv[0]
>     passed to a program's main(). For example, "os.execv('/bin/echo',
>     ['foo', 'bar'])" will only print "bar" on standard output;
>     "foo" will seem to be ignored.
>
>     (from http://www.python.org/doc/current/lib/os-process.html )
>
> in other words, you need to pass in the program name twice, to make
> sure xcopy sees the filenames as argument 1 and 2.
>
> (are you sure you want os.exec, btw?  os.system or os.spawn* might
> be a better choice...)
>
> </F>
>
>
>
>






More information about the Python-list mailing list