FAQ
- I am trying to call up an external program
with something like a "Shell" command - can not find a way of doing this
(in windows)

Any hints?

Ed Jason

Search Discussions

  • Max Noel at Feb 14, 2005 at 5:05 am

    On Feb 14, 2005, at 10:37, Lobster wrote:

    - I am trying to call up an external program
    with something like a "Shell" command - can not find a way of doing
    this
    (in windows)

    Any hints?
    What about os.system('your_command_here')?

    -- Max
    maxnoel_fr at yahoo dot fr -- ICQ #85274019
    "Look at you hacker... A pathetic creature of meat and bone, panting
    and sweating as you run through my corridors... How can you challenge a
    perfect, immortal machine?"
  • Bernard Lebel at Feb 14, 2005 at 6:20 am
    The os module is the answer. Use chdir() to make the target executable's
    directory the current directory, and then os.system( 'command' ) to run
    the actual command.


    Cheers
    Bernard


    Lobster wrote:
    - I am trying to call up an external program
    with something like a "Shell" command - can not find a way of doing this
    (in windows)

    Any hints?

    Ed Jason
  • Alan Gauld at Feb 14, 2005 at 10:52 am

    - I am trying to call up an external program
    with something like a "Shell" command - can not find a way of doing this
    (in windows)
    Look in the os module, there are several options depending on exactly
    what you need to do. The simplest option is system(). To read the
    output look at the various popen() and for more sophisticated options
    try the exec() family.

    If using system() on DOS you might look at the START DOS command
    too for the options available there.

    HTH,

    Alan G
    Author of the Learn to Program web tutor
    http://www.freenetpages.co.uk/hp/alan.gauld
  • Danny Yoo at Feb 14, 2005 at 7:05 pm

    On Mon, 14 Feb 2005, Alan Gauld wrote:

    - I am trying to call up an external program with something like a
    "Shell" command - can not find a way of doing this (in windows)
    Look in the os module, there are several options depending on exactly
    what you need to do. The simplest option is system(). To read the output
    look at the various popen() and for more sophisticated options try the
    exec() family.

    If using system() on DOS you might look at the START DOS command too for
    the options available there.
    Hi Alan and Lobster,

    I hope the plethora of choices isn't overwhelming! *grin*

    As of Python 2.4, there is a nicer external process caller in the new
    'subprocess' module:

    http://www.python.org/doc/lib/module-subprocess.html

    It tries to consolidate the major functionality of the other methods. I
    haven't played with it much, but according to the documentation, it looks
    very capable.

    Best of wishes to you!

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouptutor @
categoriespython
postedFeb 14, '05 at 3:37a
activeFeb 14, '05 at 7:05p
posts5
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase