Hi Ananymous Monk!
How it will work for you.Until you give some value to the prompt it won't work at all.In the place of prompt you have to give the value what is coming when you connect manually to the remote server .
Eg.$prompt = "\<manoj\\\@ostrich.india:\>";
See the modified code below,
Use Net::TelNet;
$prompt = "\<manoj\\\@ostrich.india:\>";
$telnet = new Net::Telnet ( Timeout=>3600,Prompt => "/$prompt/i",Errmo
+de=>'die');
$telnet->open("ostrich");
$telnet->waitfor('/login: $/i');
$telnet->print('manoj');
$telnet->waitfor('/password: $/i');
$telnet->print('manoj');
$telnet->waitfor("/$prompt/i");
print $telnet->cmd("hostname");
@hostname = $telnet->cmd("hostname");
print"Host => @hostname\n";
See the output:-
ostrich.india
Host => ostrich.india
<manoj@ostrich.india:>
Thanks and Regards,
madtoperl. |