Help required about NET::TELNET

------=_Part_24326_2033954.1133781558079
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi Folks,
    I have installed the module NET::TELNET from CPAN and when i try to
execute the below simple pgm,

--------------------****************************-----------------------
use Net::Telnet;
$telnet =3D new Net::Telnet ( Timeout=3D>100,Errmode=3D>'die');
$telnet->open('202.177.129.37');
 $telnet->waitfor('/login: $/i');
 $telnet->print('root');
 $telnet->waitfor('/password: $/i');
 $telnet->print('slr@#37');
 print $telnet->cmd('who');

---------------------------------------------------------------------------=
---
The Output of the above program is
pattern match read eof at prog.pl line 12


Please help me out folks as where may be the problem

Regards
Mazhar

------=_Part_24326_2033954.1133781558079--
0
syedmazhar
12/5/2005 11:19:18 AM
perl.beginners 29388 articles. 4 followers. Follow

2 Replies
469 Views

Similar Articles

[PageSpeed] 24

Hey Mazhar,

I don't know much about perl, but in the $telnet->waitfor method, what does the
weird parameter mean ('/login: $/i')? I thought that $ means a scalar variable
in perl. What do the forward slashes do here? Some sort of regular expression??

Vishal


Quoting Mazhar <syedmazhar.hasan@gmail.com>:

> Hi Folks,
>     I have installed the module NET::TELNET from CPAN and when i try to
> execute the below simple pgm,
> 
> --------------------****************************-----------------------
> use Net::Telnet;
> $telnet = new Net::Telnet ( Timeout=>100,Errmode=>'die');
> $telnet->open('202.177.129.37');
>  $telnet->waitfor('/login: $/i');
>  $telnet->print('root');
>  $telnet->waitfor('/password: $/i');
>  $telnet->print('slr@#37');
>  print $telnet->cmd('who');
> 
> ------------------------------------------------------------------------------
> The Output of the above program is
> pattern match read eof at prog.pl line 12
> 
> 
> Please help me out folks as where may be the problem
> 
> Regards
> Mazhar
> 




----------------------------------------
This mail sent through www.mywaterloo.ca
0
vmalik
12/5/2005 3:19:04 PM
Mazhar,

try:
$telnet->waitfor(Match => '/login: $/i');
and
$telnet->waitfor(Match => '/password: $/i');

Vishal,

Right, you want to wait for the device to return something that will match the 
expression between the slashes. In that example, you'd be waiting for the 
device to return a login prompt ending with a space and you'd ignore 
capitalization.

On Monday 05 December 2005 10:19, vmalik@engmail.uwaterloo.ca wrote:
> Hey Mazhar,
>
> I don't know much about perl, but in the $telnet->waitfor method, what does
> the weird parameter mean ('/login: $/i')? I thought that $ means a scalar
> variable in perl. What do the forward slashes do here? Some sort of regular
> expression??
>
> Vishal
>
> Quoting Mazhar <syedmazhar.hasan@gmail.com>:
> > Hi Folks,
> >     I have installed the module NET::TELNET from CPAN and when i try to
> > execute the below simple pgm,
> >
> > --------------------****************************-----------------------
> > use Net::Telnet;
> > $telnet = new Net::Telnet ( Timeout=>100,Errmode=>'die');
> > $telnet->open('202.177.129.37');
> >  $telnet->waitfor('/login: $/i');
> >  $telnet->print('root');
> >  $telnet->waitfor('/password: $/i');
> >  $telnet->print('slr@#37');
> >  print $telnet->cmd('who');
> >
> > -------------------------------------------------------------------------
> >----- The Output of the above program is
> > pattern match read eof at prog.pl line 12
> >
> >
> > Please help me out folks as where may be the problem
> >
> > Regards
> > Mazhar
>
> ----------------------------------------
> This mail sent through www.mywaterloo.ca
0
kratzers
12/5/2005 3:38:43 PM
Reply: