connection to samba server

B

Bengt Richter

very funny, ok, so now it sounds like this:
(damn smart way)

I used Google to try to find "connecting to samba server"" on the Web, but I
got no useful hits. Does anyone know where I can find programming
information on this problem?
Which problem is your problem? Do you have a samba server running? On what?
Do you have privileges to configure it (even though you don't have sufficient
knowledge at this point)? What version of windows are you running? What connects
the two? Are you trying to connect with a program or browsing "network neighborhood"?
What makes you think there is a problem? What have you tried/observed? Why are we
playing 20-questions?

Regards,
Bengt Richter
 
F

Francis Avila

Przemo Drochomirecki wrote in message ...
There's a task:
1) connect to linux samba server from windows application

After <5 minutes of googling, and knowing nothing about windows programming,
it seems that the function you need is WNetAddConnection2:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/w
netaddconnection2.asp

There is a (very popular) Python package out there which exposes the win32
api. I'm not sure what it's called. (win32api? pythonwin? win32all?)
2) compare files from samba server with files from choosen windows
catalog(s)

What's a windows catalog?
3) make backup if it's necessary.

So my problem is how to make connection with samba server having triple (IP
server, login, password) and download/upload
files. I'm working on Wk2. I was searching for suitable library but found
nothing.

You need the share name, too, I think, not just server/login/password.

Given what I think you want to do (it's not crystal clear), shouldn't you be
using rsync? My guess is that you have a bunch of windows clients and you
want to back them all up to a linux server out there somewhere. Rsync lives
for this stuff. Random Google for rsync on windows:
http://optics.ph.unimelb.edu.au/help/rsync/rsync_pc1.html Hey, look! Rsync
is hosted by samba! http://rsync.samba.org/
There's also a port of rsync to python and java (presumably, so you don't
need cygwin?) Don't know how useful they are, or if they can interop.

Why isn't the network share always connected to the windows clients? That
way you wouldn't need to back up clients to a server, but just the one
server (whose shares all the windows clients mount) to some other
server/media/drive/whatever, and you can keep all that backup machinery in a
*nix environment. This is far less complex, no?

Of course, I don't administer windows clients in big, heterogeneous
networks, so feel free to ignore my babblings.
 
F

Fredrik Lundh

Francis said:
After <5 minutes of googling, and knowing nothing about windows programming,
it seems that the function you need is WNetAddConnection2:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/w
netaddconnection2.asp

There is a (very popular) Python package out there which exposes the win32
api. I'm not sure what it's called. (win32api? pythonwin? win32all?)

win32all:

http://starship.python.net/crew/mhammond/win32/

but I'm pretty sure you can use os.system("net use ...") as well...

</F>
 
P

Przemo Drochomirecki

hi,
does anyone knows how to connect to samba server (from windows)

thx in adv.
Przemo
 
P

Przemo Drochomirecki

very funny, ok, so now it sounds like this:
(damn smart way)

I used Google to try to find "connecting to samba server"" on the Web, but I
got no useful hits. Does anyone know where I can find programming
information on this problem?

- Przemo
 
P

Przemo Drochomirecki

There's a task:
1) connect to linux samba server from windows application
2) compare files from samba server with files from choosen windows
catalog(s)
3) make backup if it's necessary.

So my problem is how to make connection with samba server having triple (IP
server, login, password) and download/upload
files. I'm working on Wk2. I was searching for suitable library but found
nothing.

Regards
Przemek Drochomirecki
 
D

David M. Wilson

Przemo Drochomirecki said:
does anyone knows how to connect to samba server (from windows)

Hello there.

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
letter, eg.:

def map_drive(local, remote, username = None, password = None):
return win32wnet.WNetAddConnection2(
win32netcon.RESOURCETYPE_DISK,
local, remote, None,
username, password,
0
)

def unmap_drive(...):
...

map_drive("Z:", r"\\mum\my_share")
# <use os.listdir to determine contents of Z:, and process>
unmap_drive("Z:")


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.
os.chdir(r"\\mum\my_share")
os.listdir(".")
# etc.


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
available?

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
community.

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
defined English?

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
to boot.

Goodnight,


David.
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top