Skip to content

Instantly share code, notes, and snippets.

@drfeelngood
Created September 25, 2012 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drfeelngood/3784077 to your computer and use it in GitHub Desktop.
Save drfeelngood/3784077 to your computer and use it in GitHub Desktop.
Net::SCP Progress bar
require 'net/scp'
# ... code ...
puts "==> Downloading #{remote_path}"
Net::SCP.download!(hostname, username, remote_path, local_path) do |c,n,r,t|
pct = r / t.to_f
cnt = ( 72 * pct ).ceil
print "%-72s %.2f%%\r" % [ ("#" * cnt), ( pct * 100 ) ]
end
puts
@drfeelngood
Copy link
Author

The output looks something like this...

==> Downloading /devl/dan/foobar.test
######################################################################## 100.00%

@drfeelngood
Copy link
Author

I used the following to create a file big enough to enjoy the progress

$  dd if=/dev/zero of=foobar.test bs=50M count=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment