capture stdout and stderror from within a Windows Service?

Tim Golden mail at timgolden.me.uk
Fri May 15 15:06:33 CEST 2009


Chris Curvey wrote:
> Ahhh, Blake put me on the right track.  If you want any of the
> streams, you have to supply values for all of them, like so:
> 
> p = subprocess.Popen(step, shell=True
>       stdout=subprocess.PIPE,
>       stdin=subprocess.PIPE,
>       stderr=subprocess.PIPE)
> 
> (stdout, stderr) = p.communicate()
> 
> and, incidentally, it appears that you have to use UNC paths in your
> Popen call -- drive letters won't work.


This is because you're running in a service. Drive letters
aren't system wide: they're per-user. The service won't
know about any drive letters you or anyone else happens
to have mapped.

TJG



More information about the Python-list mailing list