Re: os.system in a service

2009-08-06 Thread Diez B. Roggisch

Gabriel Genellina schrieb:
En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong 
lawrence...@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 21


Which isn't possible as a service.

The OP might consider using suprocess istead of os.system, and establish 
pipes to read the output of the command into a file he can analyze.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.system in a service

2009-08-06 Thread Gabriel Genellina
En Thu, 06 Aug 2009 03:59:13 -0300, Diez B. Roggisch de...@nospam.web.de  
escribió:

Gabriel Genellina schrieb:
En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong  
lawrence...@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.  
[...]



 Capture stdout and stderr and you'll probably see the error message:
 some_command logfile.txt 21


Which isn't possible as a service.


Why you say so? One should avoid using mapped drive letters and network  
shares -- that probably aren't defined for the account under which the  
service runs. And always use absolute paths. And ensure the account has  
write permissions for the output file... But other than that, os.system  
should work fine. Do I miss something?


The OP might consider using suprocess istead of os.system, and establish  
pipes to read the output of the command into a file he can analyze.


That's a good idea, although overkill for simple cases I'd say.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


RE: os.system in a service

2009-08-06 Thread Lawrence Wong

I actually found the solution.  I was trying to copy a file from another 
computer to the current one.  My 'access was denied'.  So I had to go to my 
service at Admin Tools -- Services and 'Log on as' the Administrator.  Was ok 
after that.  Thanks for your responses everyone.  

 To: python-list@python.org
 From: gagsl-...@yahoo.com.ar
 Subject: Re: os.system in a service
 Date: Thu, 6 Aug 2009 05:35:57 -0300
 
 En Thu, 06 Aug 2009 03:59:13 -0300, Diez B. Roggisch de...@nospam.web.de  
 escribió:
  Gabriel Genellina schrieb:
  En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong  
  lawrence...@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.  
  [...]
 
   Capture stdout and stderr and you'll probably see the error message:
   some_command logfile.txt 21
 
  Which isn't possible as a service.
 
 Why you say so? One should avoid using mapped drive letters and network  
 shares -- that probably aren't defined for the account under which the  
 service runs. And always use absolute paths. And ensure the account has  
 write permissions for the output file... But other than that, os.system  
 should work fine. Do I miss something?
 
  The OP might consider using suprocess istead of os.system, and establish  
  pipes to read the output of the command into a file he can analyze.
 
 That's a good idea, although overkill for simple cases I'd say.
 
 -- 
 Gabriel Genellina
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list

_
More storage. Better anti-spam and antivirus protection. Hotmail makes it 
simple.
http://go.microsoft.com/?linkid=9671357-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system in a service

2009-08-05 Thread Gabriel Genellina
En Wed, 05 Aug 2009 13:07:39 -0300, Lawrence Wong  
lawrence...@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 21

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list