develooper Front page | perl.beginners | Postings from June 2003

Re: Net::Telnet -> getline(s)

Thread Previous
From:
Mark G
Date:
June 9, 2003 16:28
Subject:
Re: Net::Telnet -> getline(s)
Message ID:
000701c32ede$bba891b0$500dbf18@tanya
> Which returns nothing.  In fact, it times out.  Can anyone offer any
> advice or an example of how to use the getlines function or a more
> elegant way to get all of the lines of the greeting?

Y not use the geline rutine like this:

<~~ cut
#untested
while(  $line = $service->getline ){
    push @lines,$line;
    next if( $line =~ m/last line/ );
}

<~~~ paste

----- Original Message ----- 
From: <perl@fatadmin.com>
To: <beginners@perl.org>
Sent: Monday, June 09, 2003 5:44 PM
Subject: Net::Telnet -> getline(s)


> Hello,
>
> I am trying to query a service using a perl script with Net::Telnet.
> The first response of the server I am checking has three lines.  For
> example:
>
> Service Name
> Date
> hello...
>
> When I use the following syntax, I get only the first line:
>
> $line = $service->getline;
> print $line;
>
> If I add the following, I get all three lines:
>
> $line = $service->getline;
> print $line;
> $line = $service->getline;
> print $line;
> $line = $service->getline;
> print $line;
>
> So I thought if I assigned the value of $service->getline to an array
> it would work:
>
> @lines = $service->getline;
> print @lines;
>
> So I looked at the Net::Telnet docs again and saw that "getlines" will
> return the next available lines so I tried this:
>
> @lines = $service->getlines;
> print @lines;
>
> Which returns nothing.  In fact, it times out.  Can anyone offer any
> advice or an example of how to use the getlines function or a more
> elegant way to get all of the lines of the greeting?
>
> I would also like an example of how to use a while loop to grab all of the
data from @lines or $line until it stops sending:
>
> while ($rrp->getline) {
>          print;
>                  }
>
> This fails because no end of data is sent after the greeting.  Without
this, I have to know the format of the response from the server ahead of
time.
>
> Thanks for any help,
>
> Random Jack
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>
>



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About