output of shell command
Steve Holden
sholden at holdenweb.com
Mon Feb 26 17:38:12 EST 2001
"Emile van Sebille" <emile at fenx.com> wrote in message
news:97diqu$nq7ks$1 at ID-11957.news.dfncis.de...
> This works on my linux box and as Joe was looking for
> 'ls -l', I assume it'll work for him too.
>
> But as I hadn't used the commands module before, I tried it
> on both my Win95 and Win2k boxes, where it failed to get the
> right info. So, either I'm doing it wrong, or the
> combination of commands and windows is broken, which I
> suspect.
>
> However, a=os.popen("dir").readlines() works on windows and
> linux. So if you're writing cross-platform, you'll want to
> keep this in mind.
>
Note, however, that under PythonWin:
>>> import os
>>> a=os.popen("dir").readlines()
Traceback (innermost last):
File "<interactive input>", line 1, in ?
WindowsError: [Errno 2] The system cannot find the file specified
Not sure why it works with a vanilla interpreter but not in PythonWin.
regards
Steve
More information about the Python-list
mailing list