Change directory with SSH : ssh « Network « Ruby






Change directory with 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

 








Related examples in the same category

1.An SSH Client
2.List server files with SSH
3.Copying a File to Another Machine