How to run commands in command line from a script

Robert Kern rkern at ucsd.edu
Fri Jul 1 05:01:29 CEST 2005


Ivan Shevanski wrote:
> I know there is an easy way to do this, and I just can not remember. I have 
> already searched where I thought the module would be. . . I just want to run 
> some name specific commands.  Is this easily possible?

Quick and dirty:

   import os
   os.system('./some --command')

More robust: Use the subprocess module.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list