I'm new on SCPClient Module
I have got copy samples as
with SCPClient(ssh.get_transport()) as scp:
scp.put(source, destination)
This code works well.
However, since I'm copy several large files, copy progress will take time, blindly waiting till it done is not good user experience.
Is there anyway that I could monitor how much has it copied? And catch the result if copy is succeed or not?
And does SCPClient have official document to read?
Did you look at the Github page? They provide an example of how to do this:
from paramiko import SSHClient
from scp import SCPClient
import sys
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('example.com')
# Define progress callback that prints the current percentage completed for the file
def progress(filename, size, sent):
sys.stdout.write("%s\'s progress: %.2f%% \r" % (filename, float(sent)/float(size)*100) )
# SCPCLient takes a paramiko transport and progress callback as its arguments.
scp = SCPClient(ssh.get_transport(), progress = progress)
scp.put('test.txt', '~/test.txt')
# Should now be printing the current progress of your put function.
scp.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With