os.system() and path problems

David Bolen db3l at fitlinxx.com
Mon Nov 13 21:49:15 CET 2000


robert_j_roberts at rl.gov (Robert Roberts) writes:

> ... I find that the cwd is exactly what I set it to. However, if I do
> a
> 
>         os.system('dir')
> 
> ...and pause it in time, I find that the dir was done on 
> 
>         c:\winnt
> 
> ...hence, the cwd as seen by Python versus the cwd seen by os.system()
> are two different things.
> 
> Any suggestions?

Yes, don't set your current directory to a UNC path, or don't run a
command that uses the CMD interpreter.  I'm not sure how it used to
work for you previously, but CMD can't handle having the current
directory be a UNC path, and if it finds it that way it'll switch back
to the main system directory before executing it's command.

It's hard to test this from the command line if you've only got CMD
around (since it doesn't let you cd to a UNC), but here's an example
from my environment using a Cygnus Unix emulation with bash (the error
message is wrapped for readability):

    ~/src> cd //ctwh01/sitedata
    //ctwh01/sitedata> cmd dir a

    '\\ctwh01\sitedata' is an invalid current directory path.
    UNC paths are not supported.

    Defaulting to Windows directory.
     Volume in drive C is SOE
     Volume Serial Number is DC33-CF3E

     Directory of C:\WINNT

    File Not Found

I'm not sure where the warning message goes, so I'm not sure if you
should be seeing it in your environment or not, but I'm betting that's
what is happening behind the scenes.

So you probably need to structure your setup so that you pass the UNC
location in as arguments rather than depending on it being your
current directory.  Either that or set up a permanent mapping to some
local drive and then use that for your current directory.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list