def do_auth (server, share, workgroup, username, password):
  return ('MYDOMAIN', 'myacct', 'mypassword')

Create the context

ctx = smbc.Context (auth_fn=do_auth)
destfile = "myfile.txt"
source = open('/home/myuser/textfile.txt', 'r')

open a SMB/CIFS file and write to it

file = ctx.open ('smb://server/share/folder/'+destfile, os.O_CREAT | os.O_WRONLY)
for line in source:
        file.write (line)
file.close()
source.close()

open a SMB/CIFS file and read it to a local file

source = ctx.open ('smb://server/share/folder/'+destfile, os.O_RDONLY)
destfile = "/home/myuser/textfile.txt"
fle = open(destfile, 'w')
for line in source:
        file.write (line)
file.close()
source.close()

results matching ""

    No results matching ""