os.system easy question

jurgen.defurne at philips.com jurgen.defurne at philips.com
Tue Jan 23 06:28:33 EST 2001


---------------------- Forwarded by Jurgen Defurne/BRG/CE/PHILIPS on 23/01/2001 12:17 ---------------------------


Jurgen Defurne
23/01/2001 12:15
To:	huwdotlynes at ic.ac.uk@SMTP 
cc:	 
Subject:	Re: os.system easy question  
Classification:	Unclassified


First, try to run your program 'program' manually over your file.
This should be debugged first.

If you want to start several versions of 'program' at once then
you should use os.fork and os.exec.

import os

for filename in list_of_files:
	rv = os.fork()
	if rv = 0:
		# We are in the child process
		os.execl("program", filename)

I recommend not only studying the os modules, but
also the manual pages about fork and exec.

Jurgen
	



huwdotlynes at ic.ac.uk@SMTP at python.org on 23/01/2001 11:56:09
Please respond to huwdotlynes at ic.ac.uk@SMTP 
Sent by:	python-list-admin at python.org
To:	python-list at python.org@SMTP
cc:	 
Subject:	os.system easy question
Classification:	

Hi all,

I'm writing a script that will run an external program over
a list of files such that:

os.system("program %s" % filename)

which would be fine if the program exited after running,
however it doesn't. So the script stops when program is run
for the first time. So the question is how to kill the
external program after it has run. Or alternatively how to
run an external program in such a way that the script will
not halt.

This is running on linux BTW.

Thanks in advance,
Huw Lynes

To reply you know what "dot" should really be.
--
http://mail.python.org/mailman/listinfo/python-list








More information about the Python-list mailing list