views:

366

answers:

4

Hello, if I explicitly attempt to list the contents of a shared directory on a remote host using python on a windows machine, the operation succeeds, for example, the following snippet works fine:

os.listdir("\\\\remotehost\\share")

However, if I attempt to list the network drives/directories available on the remote host, python fails, an example of which is shown in the following code snippet:

os.listdir("\\\\remotehost")

Is anyone aware of why this doesn't work?, any help/workaround is appreciated.

+3  A: 

May be pysmb can help

barbuza
tried it, the initial attempt seems to work :-)
Gearoid Murphy
A: 

Sorry. I'm not able to try this as I'm not in a PC. Have you tried:

os.listdir("\\\\remotehost\\")
Santi
tried it, no joy
Gearoid Murphy
A: 

Maybe the following script will help you. See http://gallery.technet.microsoft.com/ScriptCenter/en-us/7338e3bd-1f88-4da9-a585-17877fa37e3b

luc
A: 

I'm sure the OP has forgotten about this question by now, but here's (maybe) an explanation:

http://www.python.org/doc/faq/windows/#why-does-os-path-isdir-fail-on-nt-shared-directories

In case anybody else happens along this problem, like I did.

Troy