os.listdir("\\\\delta\\public")

E

Egor Bolonev

import os
print os.listdir("\\\\delta\\public")

outputs
['Bases', 'Docs', 'Drivers', 'Soft', '\xc7\xe0\xec\xe5\xed\xe0
\xd1\xe5\xf2\xe5\xe2\xee\xec\xf3 \xce\xea\xf0\xf3\xe6\xe5\xed\xe8\xfe',
'Games']


and
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?
 
M

Michael Hoffman

Egor said:
print os.listdir("\\\\delta")
WindowsError: [Errno 53] : '\\\\delta/*.*'

so how to get list of delta's shares?

I'm sure someone will post the answer shortly, but you shouldn't expect
that to work.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>hostname
MINIMOO

C:\>dir \\MINIMOO
The filename, directory name, or volume label syntax is incorrect.
 
P

Peter Hansen

Egor said:
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.

-Peter
 
I

Ishwor

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.

-Peter
[snip]

sorry my mistake :)
 
E

Egor Bolonev

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.

how to get list of shares using pywin32?
 
P

Peter Hansen

Egor said:
how to get list of shares using pywin32?

Apparently you weren't motivated enough...

This is not a Python question. It's a Windows API question.
Go find the appropriate Windows API and you'll pretty much
have your answer. There are tools called Google and
comp.os.windows* and such that would be of great help (in
conjunction with a little initiative).

*Then*, and only then, if you can't get it working but have
tried, is it really appropriate to ask here in the Python
forum how to do it. Your question at the time would say something
like "I'm trying to use the WinGetNetworkSharesA() call to
retrieve a list of shares but this isn't working... see the
following traceback for details. Thanks in advance for your help."

Or you can still just ask here for someone to do the work
for you. That does often work, strangely enough.

(It's possible that the problem stems from a language issue.
If your English is such that you are finding it very difficult
to understand our responses, or to ask a more detailed question,
then my apologies for thinking you were rude. It might help
you to say that this is the problem and then you might get
more direct help.)

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top