Copy files from Linux to Windows using Samba client in Python

Viewed 306

I am trying to copy a file from a Linux machine to a Windows shared drive. This answer shows how perform this action using the Samba client. In my case, the connection succeeds, listShares() returns the shares on the server but when I call connection.storeFile() I get Unable to connect to shared device. What am I missing?

The python code running on the Linux machine:

connection = SMBConnection(username='user1', password='password1', my_name='host1',remote_name='fs01',domain='domain', use_ntlm_v2=True)
connection.connect(ip, 139) # Returns true
file_obj = open(filename,"r") 
connection.storeFile('\\\\fs01\\data\\folder1', file1, file_obj) 

smb.smb_structs.OperationFailure: Failed to store data\folder1\file1 on fs01: Unable to connect to shared device
0 Answers
Related