connection to samba server
David M. Wilson
dw-google.com at botanicus.net
Mon Dec 15 04:25:29 CET 2003
"Przemo Drochomirecki" <pedrosch at gazeta.pl> wrote...
> does anyone knows how to connect to samba server (from windows)
Your question isn't particularly clear, however I can assume you mean
something more like "can anyone help me establish a connection to a
Samba server from Python under Windows?"
In which case, the clearest solution might be to use a suitable
Windows API call to map the remote Samba computer's share to a local
drive letter, then just access the remote Samba files via that drive
def map_drive(local, remote, username = None, password = None):
local, remote, None,
# <use os.listdir to determine contents of Z:, and process>
Alternatively if your share does not require authentication (ie. you
are pre-authenticated to the Samba server, or it has guest shares),
you may directly use UNC pathnames to access the share, eg.:
# will throw 'invalid argument' if you are not authenticated.
Alternatively, you could prepend the UNC path to each file you wish to
access, although this may be considerably slower:
to_process = [ 'input1.txt', 'input2.txt', 'job.ctl' ]
unc_path = r'\\mum\my_share'
for filename in to_process:
pathname = os.path.join(unc_path, filename)
processee = open(pathname)
Hope that helps. To the other respondees, answering in the unhelpful
manner that you did makes you no more than trolls. Has it ever crossed
your mind that in some parts of the world, the education necessary to
communicate in the accepted pythonic anal way, might not be readily
You may argue that it is better to teach someone how to ask a question
correctly, but I would rather see it as being a poor example of your
It is quite possible (gathering from the way he posted) that this
poster has never before talked on a Python user list. How do you think
he feels about his first experience with fellow Python programmers,
good or bad?
Nothing agitates me more on the Internet than people wasting each
other's time in this manner. True, the poster wasn't particularly
clear, but do you have a right to demand he posts in clear well
The Internet is a global medium, and despite popular assumption,
English is not an Internet standard. I have as much right to post in
native Belfast slang as you have to post in well written English.
Please learn to be accepting of one another, it is so much more
helpful than to try to correct something that shouldn't be corrected.
The original poster was well meaning, was your reply?
If you didn't understand the question then don't reply. Others may
well do, and the poster will quickly work out whether or not he is
being clear by the number of replies he receives.
By doing the usual "person isn't being clear, lets make an example of
him" dance, you wasted not only your own time, but his, everyone who
reads your pointless thread, and some megabytes of Internet bandwidth
More information about the Python-list