2017-12-01 10 views
0

telnet apcにログインするためにrubyスクリプトでログインしようとしています。もっとたくさんのデータを待っているRubyとtelnet

コード:私は次のエラーを受け取る

server = Net::Telnet.new("Host" => "192.168.178.240", 'Timeout' => 10, "Output_log" => "output_log", "binmode" => true ,'Waittime' => 2, "telnetmode" => true) 
server.cmd('apc') 
server.waitfor((/:.*>|More\?/)) 
print a 

:I

irb(main):025:0> Device.reboot 
Net::ReadTimeout: timed out while waiting for more data 
    from app/models/device.rb:15:in `reboot' 
    from (irb):25 
irb(main):026:0> 

server.match(/([User+Name])\w+) { |str| puts str } 
server.waitfor('password') { |str| puts str } 

詳細ログファイル、コマンドはパスワードフィールドに貼り付けています。

User Name : apc 
Password : Trying 192.168.178.240... 
Connected to 192.168.178.240. 

User Name : apc 
Password : 
+1

私はこれらの種類のPDUデバイスもSSHをサポートしていると思います。 – tadman

答えて

0

私は前にこのライブラリを使用したことがないけど、どのよう

login_info = {"Name" => "Your User name", 
       "Password" => "Your password", 
       "LoginPrompt" => /User\sName\s*:/ 
      } 
server = Net::Telnet.new("Host" => "192.168.178.240", 'Timeout' => 10, "Output_log" => "output_log", "binmode" => true ,'Waittime' => 2) 
server.login(login_info) { |c| print c } # print the output from the login attempt 
server.cmd("String" => 'apc', "Match" => /:.*>|More\?/) do |a| 
    print a # print the output as it is read in 
end 

ため、この作業はこれはあなたが今に失敗しているパスワードプロンプトセクションを乗り越えるできるようにする必要がありますんが、私ドンあなたが持っている他の意図は分かりません

関連する問題