
-
pip进行pysmb安装
pip install pysmb
-
pysmb详细功能属性请参照官方文档
-
实例代码如下
from smb.SMBConnection import SMBConnection import socket def main(): server_name = socket.getfqdn(address_ip) # server_name should match the remote machine name, or else the connection will be rejected conn = SMBConnection(username, password, 'func_handle', server_name, domain, use_ntlm_v2=True, sign_options=SMBConnection.SIGN_WHEN_SUPPORTED, is_direct_tcp=True) # tcp port: 445 || NetBIOS port: 139 connected = conn.connect(server_name, 445) # getAttributes(service_name, path, timeout=30) # list share files # listPath(service_name, path, search=65591, pattern='*', timeout=30) #file_obj = tempfile.NamedTemporaryFile() #file_attributes, filesize = conn.retrieveFile('smbtest', '/rfc1001.txt', file_obj) if '__name__' == '__main__': main()




近期评论