[python-uk] Here's a little test
python-uk@python.org
python-uk@python.org
Wed, 28 Aug 2002 16:27:16 +0100
Thanks Chris.
I've tried fiddling with this but see my reply to Simon.
Cheers.
Dale Strickland-Clark
Riverhall Systems Ltd. Custom database and Web applications.
http://www.riverhall.co.uk
Offices: London: 0870 321 0034 Wokingham: 0870 321 2378
Mobile 0701 071 DALE (3253)
-----Original Message-----
From: Chris Miles [mailto:chris@psychofx.com]
Sent: Wed, 2002 August 28 15:42
To: python-uk@python.org
Subject: Re: [python-uk] Here's a little test
One of my favorite things about Python: ask the object itself!
>>> import os
>>> print os.execl.__doc__
execl(file, *args)
Execute the executable file with argument list args, replacing the
current process.
So as *args says, after the file arg you can pass as many args as you
like.
A simple demo on Linux (don't have a win32 handy):
>>> os.execl('/bin/ls', '-a', '-l')
total 16
-r-------- 1 root users 3746 Aug 19 15:56 monitoring
drwxr-sr-x 2 root users 4096 Aug 28 11:19 RCS
-r-------- 1 root users 2835 Aug 27 15:09 skinner
-r--r--r-- 1 root users 3217 Aug 28 11:19 WEBSERVER
Although strangely the first argument is being ignored. A better
example:
>>> os.execl('/bin/echo', '111', '222', '333')
222 333
Is this a bug, or something I'm missing?
Ok, I just worked it out, in typical Unix exec fashion, the first argument
is actually the process name. A final example shows this:
>>> os.execl('/bin/sleep', 'sleeeepy', '99')
(and in another shell:)
$ ps -ef |grep slee
cmiles 25260 22756 0 15:39 pts/4 00:00:00 sleeeepy 99
Not sure if win32 follows this behaviour as closely.
Hope that helps somebody anyway!
CM
On Wed, Aug 28, 2002 at 03:27:36PM +0100, dale@riverhall.co.uk wrote:
> I've posted this on clp but not had a response. I thought I'd test you
guys
> :o)
>
>
> I have a little program I've converted from Javascript which I use
> frequently. It doesn't work in Python because the last line keeps
> throwing the error:
>
> Traceback (most recent call last):
> File "I:\batch\ie.py", line 22, in ?
> os.execl(iepath, args)
> File "C:\Python22\Lib\os.py", line 266, in execl
> execv(file, args)
> TypeError: execv() arg 2 must contain only strings
>
> I have tried a variety of formats for the os.execl function,
> including:
>
> os.execl(iepath, (args, ))
> os.execl(iepath, [args])
> os.execl(iepath, args)
>
> but it always complains about arg 2 in this way.
>
> What is execl on about?
>
> Any help appreciated.
--
Chris Miles
chris@psychofx.com
http://www.psychofx.com/chris/
_______________________________________________
python-uk mailing list
python-uk@python.org
http://mail.python.org/mailman/listinfo/python-uk