Ruby 改变 SSH 上的当前目录,rubyssh,ruby代码requir
分享于 点击 29012 次 点评:37
Ruby 改变 SSH 上的当前目录,rubyssh,ruby代码requir
ruby代码
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.exitend
用户点评