in reply to Re^2: Telnet in perl
in thread Telnet in perl

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.

Replies are listed 'Best First'.
Re^4: Telnet in perl
by Anonymous Monk on Jun 26, 2006 at 13:21 UTC
    Hey madtoperl,
    Lot of Thanks.Ofcousre,I never assigned the promp previously,now it is working fine.
    Thanks for your help.