Answers for "paramiko count file"

1

paramiko count file

import paramiko

ip   =  'your remote ip'
username  =  'your user_name'
password  =  'your password'

path = 'your path you want to count file'

ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username=username, password=password)
sftp = ssh.open_sftp()
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('cd ' + path + ' && ls | wc -l')

print(ssh_stdout.read().decode("utf-8"))
Posted by: Guest on December-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language