How can I interrupt os.system(cmd)?

Discussion in 'Python' started by Carl, Nov 21, 2004.

  1. Carl

    Carl Guest

    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
     
    Carl, Nov 21, 2004
    #1
    1. Advertising

  2. 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
     
    Mathias Waack, Nov 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Achim Domma (Procoders)

    read input for cmd.Cmd from file

    Achim Domma (Procoders), Jun 3, 2005, in forum: Python
    Replies:
    2
    Views:
    8,098
    Peter Otten
    Jun 3, 2005
  2. Sarir Khamsi

    Interpreter-like help in cmd.Cmd

    Sarir Khamsi, Jun 9, 2005, in forum: Python
    Replies:
    4
    Views:
    387
    Bengt Richter
    Jun 26, 2005
  3. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    [exec cmd for cmd in cmds]

    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Mar 8, 2006, in forum: Python
    Replies:
    3
    Views:
    397
    Scott David Daniels
    Mar 8, 2006
  4. Diez B. Roggisch

    pydb remote debugging/cmd.Cmd over socket?

    Diez B. Roggisch, May 28, 2008, in forum: Python
    Replies:
    2
    Views:
    558
    Diez B. Roggisch
    May 29, 2008
  5. Diez B. Roggisch

    cmd.Cmd bug or at least docu-bug

    Diez B. Roggisch, May 29, 2008, in forum: Python
    Replies:
    1
    Views:
    347
    Michele Simionato
    May 29, 2008
Loading...

Share This Page