os.system in a service

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Aug 6 01:30:58 EDT 2009


En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong  
<lawrencew00 at hotmail.com> escribió:

> I wrote a program which runs a .bat file using os.system like:  
> 'os.system(pathToBatFile)' and everything was good.  Then I decided to  
> turn my program into a service as opposed to being run with the command  
> prompt showing.  When my program became a service, I noticed that the  
> os.system command to run my .bat file was no longer working.  By 'not  
> working' I mean no exception is thrown, but it was as if the line with  
> os.system(pathToBatFile) did not exist.  I was wondering why this is and  
> if there is a way to fix this or what an alternative to using os.system  
> to run my .bat file was?

Capture stdout and stderr and you'll probably see the error message:

some_command >logfile.txt 2>&1

-- 
Gabriel Genellina




More information about the Python-list mailing list