Ruby - Problems with Expect and Pty

旧巷老猫 提交于 2019-12-03 08:39:21

For this I recommend using the net-ssh gem: sudo gem install net-ssh: http://net-ssh.rubyforge.org/ssh/v2/api/index.html

The code goes a little like this:

require 'rubygems'
require 'net/ssh'

Net::SSH.start('your-server', 'username', :password => "password") do |ssh|
  puts ssh.exec!("ls -la")
end

Check out http://www.42klines.com/2010/08/14/what-to-expect-from-the-ruby-expect-library.html - it has some nice examples of using PTY with and without Ruby's expect.

I often find it easier to only use PTY, as I can look at my "buffer" and work out what's happening.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!