does os.popen() search the path?

Mark Hammond MarkH at ActiveState.com
Sat Oct 14 10:10:11 EDT 2000


<jschmitt at vmlabs.com> wrote in message
news:8s8ubv$21q$1 at nnrp1.deja.com...

> I can get it to print the PATH environment variable and it tells me
> that things like 'grep' are in my path.  Yet,
>
> cmd = os.popen( 'grep' )
>
> never launches.

Never launches, or launches and quickly terminates?  "grep" with no
options will attempt to read from stdin, but no stdin it setup, so it
will exit immediately.

eg:

>>> len(os.popen("grep --help").read())
2112

> Another thing, I can also do this:
>
> cmd = os.popen( 'foo.cmd' )

os.popen simply uses "cmd.exe" (or whatever your COMSPEC is, etc), so
whatever behaviour you are seeing is cmd.exe at work.

Have you tried:

cmd = os.popen( os.path.abspath('foo.cmd') )

?

Mark.





More information about the Python-list mailing list