【发布时间】:2020-04-21 13:53:53
【问题描述】:
实际上,我需要使用 Paramiko 检查文件。我收到以下错误。如果你们中的任何人能解决这个问题,将会很有帮助。
import paramiko
try:
host = '23.120.7.00'
username = 'UNAME1'
password = 'UNAME12'
file_to_check = '\\\\ipconnect\\ABCS\\IPXADEP\\file1.dta'
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host,username=username, password=password)
channel = client.get_transport().open_session()
channel.exec_command('cd \\\\ipconnect\\ABCS\\IPXADEP')
stdin, stdout, stderr = channel.exec_command('ls')
stdout = channel.makefile().read()
output = stdout.decode('utf-8').split('\n')[:-1]
print(output)
client.close()
except Exception as e:
print(str(e))
我收到以下错误:
无法解压不可迭代的 NoneType 对象
我需要检查上述文件是否存在于该特定文件夹中。为什么不能列出文件?任何帮助将不胜感激。
【问题讨论】:
标签: python ssh sftp paramiko pysftp