Actually, I need to check for a file using Paramiko. I am getting the following error. It would be helpful if any of you could resolve this.
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))
I am getting the following error:
cannot unpack non-iterable NoneType object
I need to check whether the file mentioned above is present or not in that particular folder. Why isn't it possible to list out the files? Any help would be highly appreciated.