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

Hi Shmem/jesuashok,

I tried both of yours code and got the output as follows,
<susan@sohuswmisr:>perl 354.pl Host =>
Expected output
Host => susan@dohudemidt
Pls help me monks.
Thanks.

Replies are listed 'Best First'.
Re^3: Telnet in perl
by madtoperl (Hermit) on Jun 26, 2006 at 13:14 UTC
    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.
      Hey madtoperl,
      Lot of Thanks.Ofcousre,I never assigned the promp previously,now it is working fine.
      Thanks for your help.