Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Python SMB Connection
-
Hey Guys,
I have a Problem and i don't find my solution...
Here's my test Code:import smb from smb.SMBConnection import SMBConnection from nmb.NetBIOS import NetBIOS netbios = NetBIOS() share_name = "share" user_name = "user" password = "passwd" server_IP = "xxx.xxx.xxx.251" local_machine_name = socket.gethostname() server_machine_name = netbios.queryIPForName(server_IP) print(server_machine_name[0]) # create and establish connection conn = SMBConnection(user_name, password, local_machine_name, server_machine_name[0], domain="WORKGROUP", use_ntlm_v2=True) # 139 # 445 print(conn.connect(server_IP, 445))
i get every Time this Message:
ELEKTROTECHNIK False
but the Function
conn.connect
return on Success True... not False....
i Have no idea what i'm doing wrong...im trying to connect to my Synology NAS 718
i hope you guys know what im doing wrong....
Thanks!!
-
@DavinE I always use it with port=139 on my Western Digital NAS.
-
@DavinE said:
local_machine_name = socket.gethostname()
Try
local_machine_name = socket.gethostname()[0]
-
@cvp i tried both :( same result...
-
@DavinE said:
server_machine_name = netbios.queryIPForName(server_IP)
Sorry, error😢 , try
server_machine_name = netbios.queryIPForName(server_IP)[0]
-
-
-
@cvp
yes, sorry :(I used both ports
-
@DavinE strange, I use this successfully
ip = bios.queryName(self.smb_name) return ip[0]
-
-
@DavinE sorry, a mistake more,
bios = NetBIOS() srv_name = bios.queryIPForName(remote_smb_ip, timeout=timeout) return srv_name[0]
-
@cvp
hmm...
I get the same output as i get with my codeELEKTROTECHNIK
-
-
@DavinE said:
local_machine_name = socket.gethostname()
server_machine_name = netbios.queryIPForName(server_IP)Did you try with
local_machine_name = socket.gethostname()[0] server_machine_name = netbios.queryIPForName(server_IP)[0]
-
@cvp said:
@DavinE said:
in your case whats the self.smb_name? Server Name
Yes
When i use your code above
ip = bios.queryName(self.smb_name) return ip[0]
server_machine_name = netbios.queryIPForName(server_IP)[0]
print(server_machine_name)
ELEKTROTECHNIK
print(local_machine_name)Davin
print(netbios.queryName(server_machine_name))and here None
why none ?
-
@cvp said:
@DavinE said:
local_machine_name = socket.gethostname()
server_machine_name = netbios.queryIPForName(server_IP)Did you try with
local_machine_name = socket.gethostname()[0] server_machine_name = netbios.queryIPForName(server_IP)[0]
This did not work here i get only the first letter
local_machine_name = socket.gethostname()[0]
in my case
D
-
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
-
@cvp said:
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
yeah i tried it but i can retry it...
i do not have
SMB_client
installed
should i install it ? and try -
@DavinE did you see the link in my post?
-