Example of pysmb

前端 未结 3 701
醉梦人生
醉梦人生 2021-02-13 23:57

Could you give me an example of using pysmb library to connect to some samba server? I\'ve read there\'s class smb.SMBConnection.SMBConnection(username, password, my_name, remot

3条回答
  •  旧巷少年郎
    2021-02-14 00:24

    The SMBConnection class will allow you to access the files on the remote Samba server in blocking mode.

    To retrieve the list of the files in a shared folder on the remote server,

    from smb.SMBConnection import SMBConnection
    conn = SMBConnection(userid, password, client_machine_name, remote_machine_name, use_ntlm_v2 = True)
    conn.connect(server_ip, 139)
    filelist = conn.listPath('shared_folder_name', '/')
    

    The returned filelist will be a list of SharedFile instances.

    More examples can be found in the tests/SMBConnectionTests folder in the pysmb source package.

提交回复
热议问题