ysitbook 发表于 2011-04-07 16:46

Ruby 改变 SSH 上的当前目录

require 'rubygems'
require 'net/ssh'


Net::SSH.start('example.com', :username=>'yourName',
               :password=>'mypass') do |session|
shell = session.shell.sync
puts "#{shell.pwd.stdout}"
shell.cd 'test_dir'
puts "#{shell.pwd.stdout}"
puts 'Directory contents:'
puts shell.ls("-l").stdout
shell.exit
end
页: [1]
查看完整版本: Ruby 改变 SSH 上的当前目录