473,654 Members | 3,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

popen pipes fail when cwd is a UNC path

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("\\\\T imb\\Python23")
os.getcwd() '\\\\Timb\\Pyth on23' 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
Jul 18 '05 #1
2 3423
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.********@niwa .co.nz
National Institute for Water and Atmospheric Research (NIWA)
Jul 18 '05 #2
In article <ch**********@n ewsreader.mailg ate.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
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1036
by: Mark Sandler | last post by:
Hi, When i create a process using popen and then if i decide that i am not interested in keeping the process pipes anymore, and I forget the correspond variables . Then, if python tries to destroy pipes and get locked on pipe.close(), until the child process terminates... While this seem to follow specifications (close waits until pipes closes on the other end, and destructor calls close()), it seems like a rather weird behaviour to me:...
4
2060
by: Kevin Walzer | last post by:
I'm trying to structure a Python script that streams output over a pipe. Here is my code: import os cmd = os.popen('echo foo | sudo -S /usr/sbin/tcpdump -en1') cmd.read() This returns output of "". I'm expecting the standard output of "tcpdump
2
3478
by: hubritic | last post by:
I am trying to set off commands on Windows 2003 from python. Specifically, I am trying to use diskpart with a script file (pointed to with path). cmd = p = Popen(cmd, shell=True) The script is meant to loop through twice. It will do so if I comment out the Popen call and print cmd instead. But when Popen is called, one disk will be formated, but not the next.
13
5108
by: bayer.justin | last post by:
Hi, I am trying to communicate with a subprocess via the subprocess module. Consider the following example: <subprocess.Popen object at 0x729f0> Here hey is immediately print to stdout of my interpreter, I did not type in the "hey". But I want to read from the output into a string, so I do
8
2885
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2 etc. the child process is interactive: it asks for input then spits out some output, asks for more input then spits out some output. for example, consider the trivial child program:
3
1715
by: Ratko | last post by:
Hi all, I have a python gui app that launches multiple applications using subprocess.Popen class and prints their output in the gui (using PIPEs, threads and wxPython). Everything works great but the problem is that some applications should run in the background (ie they don't close when the gui closes) so next time when you start the gui it will not have a handle on those processes that are still running and therefore won't be able to...
3
5033
by: DBC User | last post by:
Hi all, I would like to know is there a way to find out if any named pipes are running in a box. How can I go about doing that? Or is there a way to find out if a particular named pipe already running? Thanks
25
2763
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the object itself is a subprocess, not a "popen". It seems that it would be more accurate to just name the class Subprocess, can anyone explain why this is not the case? Thank you.
1
8630
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output parameters that are passed and captured from this exe. When I use the class outside of a service using either subprocess.Popen or os.popen2 work just fine. When I use this class inside a Windows service it doesn't work. It doesn't crash the...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.