Odd problem running command-line python scripts (win2k)

Trent Mick trentm at ActiveState.com
Thu Dec 5 12:45:40 EST 2002


[Brian Kelley wrote]
> 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.

1. What is the first python.exe on your PATH? This is the Python that is
   being run in the first command.
2. Next, run "regedit" to browse your registry.
   - Open HKEY_CLASSES_ROOT.
   - Go to the ".py" key.
   - What is the "(Default)" value of that key? For me it is
     "Python.File".
   - Go to the "Python.File" (or to the key named in the previous step)
     key off of HKEY_CLASSES_ROOT.  
   - That entry should have a key hierarchy under it that looks like
     this:
        Python.File
            shell
                open
                    command    <--- What is the "(Default)" value here?
     That "(Default)" value is how you second invocation of test_os.py
     is being run. For me this string is:
        C:\Python22\python.exe "%1" %*
     The %1 is replaced with "test_os.py" and %* with any subsequent
     args.


If (1) and (2) result in different Pythons then that may be your
problem.

Trent


-- 
Trent Mick
TrentM at ActiveState.com




More information about the Python-list mailing list