Zhao_Yi
(Zhao Yi)
7 September 2008 09:27
1
I use this code to telnet to a Windows Xp machine.
tn=Net::Telnet.new("Host" => "localhost","Timeout" => 10,"Prompt" =>
/[$%#>] \z/n)
tn.login("user", "123456"){|c| print c}
The output will be:
"
Welcome to Microsoft Telnet Service
login: zhaoyi
password:
"
and then timeout.
···
--
Posted via http://www.ruby-forum.com/ .
Zhao_Yi
(Zhao Yi)
7 September 2008 10:26
2
I know what wrong with these code. It is because the password prompt is
different with the default one. It works when I set the PasswordPrompt
value. But after login, when I run a command I will get time out error.
Please see my code:
tn=Net::Telnet.new("Host" => "localhost","Timeout" => 10,"Prompt" =>
/[$%#>] \z/n){|c| print c}
tn.login({"Name"=>"user","Password" =>
"123456","LoginPrompt"=>/[Ll]ogin[: ]*\z/n,"PasswordPrompt"=>/password[:
]*\z/n}){|c| print c}
tn.cmd("dir"){|c| print c}
···
--
Posted via http://www.ruby-forum.com/ .