listing network shares with python

Gearoid Murphy picture Gearoid Murphy · Sep 22, 2009 · Viewed 12.7k times · Source

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.

Answer

Victor Kotseruba picture Victor Kotseruba · Sep 22, 2009

May be pysmb can help