I want to go to remote host and do some tasks. One of them is to check the existence of a directory.
import paramiko import os, sys ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) mykey=paramiko.RSAKey.from_private_key_file("Key_location") ssh.connect('1.2.3.4', port = 3441, username=ba, pkey = mykey) stdin, stdout, stderr = ssh.exec_command('cat happy.txt') out = stdout.readlines() if os.path.isdir('/home/user/abc): #do something else: stdin, stdout, stderr = ssh.exec_command('rm -r abc') Issue is that the code is not able to check if a directory exsist or not The code is able to get the content of happy.txt but not able to check the directory in remote host.
https://stackoverflow.com/questions/66728463/check-the-existence-of-a-directory-in-remote-host-using-paramiko March 21, 2021 at 11:07AM
没有评论:
发表评论