[Tutor] Run a cmd program

Kent Johnson kent37 at tds.net
Tue Aug 9 15:07:38 CEST 2005


Øyvind wrote:
> Hello.
> 
> I need to run a program
> (http://www.microsoft.com/ntserver/nts/downloads/management/uptime/default.asp)
> thru Python. It is normally run such as "uptime AUTO-SRV-001 /s
> /d:04/01/2005" in the command prompt. Is it possible to run a already
> compiled exe file in Python and thereafter get the result out? What
> module/command should I look for to run another program? Googling have
> only given me results about how to run Python..

Try the subprocess module, something like
results = subprocess.Popen('uptime AUTO-SRV-001 /s /d:04/01/2005', stdout=subprocess.PIPE).communicate()[0]

Kent



More information about the Tutor mailing list