By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,812 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,812 IT Pros & Developers. It's quick & easy.

How can I interrupt os.system(cmd)?

P: n/a
Dear friends,

I have written a small Python program that executes "cmd" via
os.system(cmd).

My problem is that "cmd" runs on forever.

More specifically, I want to run "cmd" for one hour on a regular day-to-day
basis by using crontab as a scheduler.

What options do I have to control execution of external programs from
Python?

Carl

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Carl wrote:
What options do I have to control execution of external programs
from Python?


You have the same options as your OS offers. At least under Unix you
can run a command by using one of the popen()-functions or using the
commands module (I would suggest the latter for you). All these
procedures give you the process id (pid) of the started process. You
can wait() for this process or you can control it by sending it
signals using the kill() function. The python docs contains all
information necessary to use these functions. Read the pages about
the modules os, popen and commands. Most of these functions should
be available under all OS.

Mathias
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.