Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created October 28, 2010 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dongyuwei/650555 to your computer and use it in GitHub Desktop.
Save dongyuwei/650555 to your computer and use it in GitHub Desktop.
使用ruby scp库批量上传文件夹,并且显示进度
#!/usr/bin/ruby
#@auther newdongyuwei@gmail.com
require 'rubygems'
require 'net/ssh'
require 'net/scp' #gem install net-scp
host = "ip address"
username = "your name"
password = "your password"
source = "/home/xxx/xx/"
target = "/opt/"
recursive = true #recursive uploads directory
Net::SCP.start(host, username, :password => password) do |scp|
scp.upload!(source, target,:recursive => recursive)do |ch, name, sent, total|
#progress reports
puts "#{name}: #{sent}/#{total}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment