自分用メモ require 'net/telnet' telnet=Net::Telnet.new("Host" => "IPを書く") telnet.login("user","password") #後ろにブロックをつけると結果が表示される telnet.cmd("ls"){|c| print c} #suするにはこんな感じ telnet.cmd({"String" => "su - user2","Match" => /^Password:/}) telnet.cmd("password2") telnet.cmd("pwd"){|c| print c} telnet.cmd("exit") #user2をexit telnet.cmd("exit") #userをexit telnet.close telnet.cmd("ls")とうつと、cmdメソッドは、「ls」という文字列に