system call in python

satish k.chimakurthi skchim0 at engr.uky.edu
Thu Aug 14 01:45:51 EDT 2003


Hi,

I think you can do the following:

import commands
commands.getstatusoutput("...your command to execture program...")

SATISH


On Thursday 14 August 2003 01:37 am, Graham Fawcett wrote:
> Catherine Yang wrote:
> >Hi,
> >
> >A question about how to execute a system command from python program. e.g.
> >in a python script, I need to run another program written in C++, and
> > after that come back to the same python program.
> >
> >Is it the system module, and which function do I use to do this?
> >
> >Thanks a lot
> >Catherine
>
> Probably you are looking for os.system, as in:
>
>     import os
>     cmd = 'ls -l /usr/bin'
>     os.system(cmd)
>
> Note that this will not capture the output of the system command; you
> can use the os.popen family of commands to do that.
>
> -- Graham

-- 
SATISH K.CHIMAKURTHI
GRAD. RESEARCH ASSISTANT
UNIVERSITY OF KENTUCKY
LEXINGTON
KENTUCKY STATE 






More information about the Python-list mailing list