Skip to content

Instantly share code, notes, and snippets.

@mccxj
Created June 24, 2009 01:33
Show Gist options
  • Save mccxj/134952 to your computer and use it in GitHub Desktop.
Save mccxj/134952 to your computer and use it in GitHub Desktop.
# 因为使用ssh2的时候,总是出错,所以改用ssh1
require 'rubygems'
gem 'net-ssh', '1.1.4'
require 'net/ssh'
# 用来更新32和63的ruby小脚本
cmd = Proc.new do |shell|
shell.cd("/opt/gst")
print "current directory:",shell.pwd.stdout
print "current ruby version:",shell.ruby("-v").stdout
print shell.sh("/opt/getupdate.sh").stdout
shell.exit
end
Net::SSH.start('192.168.1.32', :username => 'root', :password=>'psword') do |session|
shell = session.shell.sync
cmd.call(shell)
p "192.168.1.32 done!"
end
Net::SSH.start('192.168.1.63', :username => 'root', :password=>'psword') do |session|
shell = session.shell.sync
cmd.call(shell)
p "192.168.1.63 done!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment