newbie script

Ed a.edmondson at eris.qinetiq.com
Wed Sep 24 09:56:09 EDT 2003


os.system('xyz') runs in a shell, and when it exits returns its exit status.
e.g.:
a=os.system('ls bogus_directory')
if bogus_directory exists then 'a' = 0, and if not 'a' = 1.

while 1:
        os.system('xyz')

will run the program xyz, and as soon as xyz exits it will run it again -
and so on.

-Ed

ataraxia2500 wrote:

> ok thanx I'm on linux, what I want  basically is the script to launch xyz
> and then check if it's running using os.system('xyz'), and if it's not
> running I want the script to relaunch xyz. So could u tell me please also
> how to launch or relaunch a programme please :)
>> 
>> If you're UNIX based:
>> 
>> os.system('xyz') will return the exit status of your program xyz.
>> More importantly for you, it will return!
>> 
>> So try an (ugly) loop like:
>> 
>> import os
>> while 1:
>>         os.system('xyz')
>> 
>> 
>> -Ed
>> 
>> ataraxia2500 wrote:
>> 
>>> I wanna do a script that launch a programm xyz and relaunch xyz if it
>>> crashes. what kind of module do I need for such a task?
>>

-- 
##############################################################################
Andrew Edmondson
PGP Key:
http://search.keyserver.net:11371/pks/lookup?op=get&search=0xCEE814DC
PGP Fingerprint: 7B32 4D1E AC4F 29E2 9EAA 9550 1A3D BBA4 CEE8 14DC





More information about the Python-list mailing list