[Tutor] Executing dos .bat file with Python script

Bernard Lebel python at bernardlebel.com
Sat Jul 24 22:54:38 CEST 2004


(sorry Alan if you have received this privately, I'm not used to the need to
use reply-all to send back to the list)


Thanks Alan.

However.... it doesn't seem to work as expected?
My bat file starts a dos command prompt within the Softimage|XSI
environment. But when executing the command, well, a command prompt pops but
closes immediately!

Python code:
oFile = file( 'C:\\Python23\\Lib\\experimentation\\xsi.bat', 'r' )
os.system( str( oFile.read() ) )

Bat file (xsi.bat) code (this code is the actual code used to launch the XSI
command prompt):
@echo off
title "SI Command Prompt"
cmd /K call C:\Softimage\XSI_3.5.1\Application\bin\setenv.bat
echo on


I suspect that the problem is with the fact that my bat file is calling
another bat file, but usually if I double-click on a bat file containing
that code it works....

Thanks
Bernard


----- Original Message ----- 
From: "Alan Gauld" <alan.gauld at blueyonder.co.uk>
To: "Bernard Lebel" <python at bernardlebel.com>; <tutor at python.org>
Sent: Saturday, July 24, 2004 8:25 PM
Subject: Re: [Tutor] Executing dos .bat file with Python script


> > Let say I have a python script that write a .bat file, with the
> commands and
> > arguments. Now how can I use that same python script to actually
> execute the
> > .bat file in the Windows environment? Any direction would be
> appreciated.
>
> Use os.system()
>
> or os.popen() if you want to read the output...
>
> Alan G.
>
>
>



More information about the Tutor mailing list