FAQ
In my recent experience, popen os pipes always fail when cwd is a UNC
path. Can anyone shed any light on this? Although I've seen lots of
UNC path-related problems in this newsgroup, I've not been able to
find anything specifically about os pipes and UNC paths.

Here's a session dump that demonstrates what I'm talking about:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
os.getcwd()
'c:\\Python23'
f=os.popen("dir"); r=f.read(); print f.close()
None
os.getcwd()
'c:\\Python23'
os.chdir("c:\\")
os.getcwd()
'c:\\'
f=os.popen("dir"); r=f.read(); print f.close()
None
os.chdir("\\\\Timb\\Python23")
os.getcwd()
'\\\\Timb\\Python23'
f=os.popen("dir"); r=f.read(); print f.close()
1

As you can see, this last pipe fails. This only happens when cwd is a
UNC path. Please let me know if you have seen this, solved this, know
a nice workaround, etc. as I find this quite annoying.

Thanks,
Tim

Search Discussions

  • Mark Hadfield at Sep 8, 2004 at 11:01 pm

    Tim Black wrote:
    In my recent experience, popen os pipes always fail when cwd is a UNC
    path. Can anyone shed any light on this? Although I've seen lots of
    UNC path-related problems in this newsgroup, I've not been able to
    find anything specifically about os pipes and UNC paths.
    It's a problem with the Windows command interpreter (cmd.exe on the NT
    family) which gets invoked by popen. To demonstrate this. try cd'ing to
    a UNC path. You will get a message like

    '\\foo\bar' is an invalid current directory path. UNC paths are not
    supported.


    --
    Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
    m.hadfield at niwa.co.nz
    National Institute for Water and Atmospheric Research (NIWA)
  • Steve Christensen at Sep 9, 2004 at 5:53 pm

    In article <cho314$4e1$1 at newsreader.mailgate.org>, Mark Hadfield wrote:
    Tim Black wrote:
    In my recent experience, popen os pipes always fail when cwd is a UNC
    path. Can anyone shed any light on this? Although I've seen lots of
    UNC path-related problems in this newsgroup, I've not been able to
    find anything specifically about os pipes and UNC paths.
    It's a problem with the Windows command interpreter (cmd.exe on the NT
    family) which gets invoked by popen. To demonstrate this. try cd'ing to
    a UNC path. You will get a message like

    '\\foo\bar' is an invalid current directory path. UNC paths are not
    supported.
    It won't be directly applicable to the original problem... But, you can
    use 'pushd' on a UNC path. It will temporarily map the UNC path to a
    drive letter. When you do a 'popd' it will unmap the drive letter.

    -Steve

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 8, '04 at 10:48p
activeSep 9, '04 at 5:53p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2021 Grokbase