Odd problem running command-line python scripts (win2k)

Steve Holden sholden at holdenweb.com
Thu Dec 5 12:25:25 EST 2002


"Brian Kelley" <bkelley at wi.mit.edu> wrote in message
news:3DEF7F04.70607 at wi.mit.edu...
> Here is a test script
> --- test_os.py ---
> import os
> print os.system("DIR > t")
>
> F:\> python test_os.py
> 0
> F:\>
>
> t has the correct listing in it
> F:\> del t
> F:\> test_os.py
> 1
> F:\>
>
> t doesn't exist
>
> Does anybody have a clue what is going on here?  Apparently, I can't get
> any system call to work when the program is not explicitly called by
python.
>
> I'm using the default python 2.2.1 installation on windows2000.
>

If you'd said you were running Windows NT I would have suggested this is
traceable to a bug in the Windows command procesor, which apprently won't
redirect the output of commands successfully if the interpreter is divined
from the program's extension rather than being entered directly.

I'm guessing, though. Surely the best advice is "don't do that!"?

Bizarrely, with 2.2.1 build 222 from ActiveState on Windows 2000 Pro I don't
get the error you do, and the file is created whether or not I specify the
interpreter on teh command line.

Time for Windows 2000 Service Pack 2? That's what I'm running.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list