Peter Hansen peter at engcorp.com
Sat Dec 4 17:40:15 CET 2004

Egor Bolonev wrote:
> import os
> print os.listdir("\\\\delta")
> outputs
> Traceback (most recent call last):
>  File "C:\Documents and Settings\Егор\My Documents\Scripts\test.py", 
> line 4, in ?
>    print os.listdir("\\\\delta")
> WindowsError: [Errno 53] : '\\\\delta/*.*'
> so how to get list of delta's shares?

As Michael points out, there's no reason to think that should
have worked.  You can't do a directory of a computer, only
a drive on the computer, and likewise you can't do a directory
of a computer on a network, only of the resources is shares.

Try grabbing the output of os.popen(r"net view \\delta") and
parse it to get a list of the shares:

c:\>net view \\monolith
Shared resources at \\monolith
Share name  Type   Used as  Comment
Printer     Print           Microsoft Office Document Image Writer
Printer2    Print           hp psc 1310 series
Printer3    Print           HP LaserJet 4
shared      Disk   I:
SharedDocs  Disk
The command completed successfully.

No doubt you can also do this much more easily with the pywin32
package, or via COM (using pywin32 or ctypes), but I'll leave
that response to someone else.  Or you could figure it out yourself
if you are motivated enough.


More information about the Python-list mailing list