Tim P. wrote:
Just curious, but are you trying to connect to an APC Power
Distribution Unit? Your choice of variable names – @apc_ip – just
made me think of the APC PDUs we have here at work.
Yes I work with APC PDU.
Try setting ‘Output_log’ to a filename when you create your telnet
session. This will copy all telnet traffic to the given log file.
Ok, so i tried with function made to that : ‘login’. Here is my code :
###################Start of code
require ‘net/telnet’
class Host
def initialize(host_ip, apc_ip, slot_number)
@host_ip = host_ip
@apc_ip = apc_ip
@slot_number = slot_number
end
def reboot
telnet_session = Net::Telnet.new(‘Host’ => @apc_ip, ‘Output_log’ =>
‘my_log.txt’)
telnet_session.login(‘LoginPrompt’ => ‘User Name’,
‘PasswordPrompt’ => ‘Password’,
‘Name’ => ‘cortdav’,
‘Password’ => ‘cortdav’)
end
end
Dione = Host.new(“3.249.13.36”, “3.249.13.24”, 2)
Dione.reboot
###################End of code
I obtained in the log :
<<
Trying 3.249.13.24…
Connected to 3.249.13.24.
User Name :
So, ‘User Name’ is what I wait for. But it crashes.
It works if I write :
telnet_session.login('LoginPrompt' => '',
'PasswordPrompt' => '',
'Name' => 'cortdav',
'Password' => 'cortdav')
But the day I’ll need to wait for an expression, I will have the same
problem, so I need to find the solution now. Reading and Reading the
docs, and I don’t find the problem…