I'm using Paramiko's SFTPClient to transfer file between hosts. I want my script to print the file transfer progress similar to the output seen using scp.
$ scp my_file user@host
user@host password:
my_file 100% 816KB 815.8KB/s 00:00
$
Any idea?
Thanks in advance
SSHClient. A high-level representation of a session with an SSH server. This class wraps Transport , Channel , and SFTPClient to take care of most aspects of authenticating and opening channels. A typical use case is: client = SSHClient() client.
pysftp is a wrapper around Paramiko with a more Python-ish interface. pysftp interface does not expose all of the features of Paramiko. On the other hand, pysftp implements more high-level features on top of Paramiko, notably recursive file transfers.
Paramiko relies on cryptography for crypto functionality, which makes use of C and Rust extensions but has many precompiled options available. See our installation page for details. SSH is defined in RFC 4251, RFC 4252, RFC 4253 and RFC 4254. The primary working implementation of the protocol is the OpenSSH project.
Paramiko helps you automate repetitive system administration tasks on remote servers. More advanced Paramiko programs send the lines of a script one at a time. It does this rather than transacting all of a command, such as df or last , synchronously to completion.
Use the optional callback parameter of the put function. Something like this:
def printTotals(transferred, toBeTransferred):
print "Transferred: {0}\tOut of: {1}".format(transferred, toBeTransferred)
sftp.put("myfile","myRemoteFile",callback=printTotals)
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