calling programs from python

Kristofer Wouk kristofer at hotpop.com
Tue Dec 2 17:02:26 CET 2003


David MacQuigg wrote:
> On Mon, 01 Dec 2003 19:27:34 -0500, "RR" <ergodicsum at yahoo.com> wrote:
> 
> 
>>Hello,
>>
>>I am trying to call a program in python as I would call it in the command
>>line. For example I want to do the following from python: command > file.
>>Then read this file. How do I call "command > file" ? Much help
>>appreciated.
> 
> 
> Use os.system()  For example, on Unix:
> 
>>>>import os
>>>>os.system( 'command > file' )
> 
> and on Windows:
> 
>>>>os.system('start C:\Python23\python.exe')
> 
> 
> -- Dave
This will work too:

import os
os.popen('command > file')

Kris





More information about the Python-list mailing list