Net::Telnet - problem with \n characters 
Author Message
 Net::Telnet - problem with \n characters

I am using the Net::Telnet module to connect to a remote access server to
get information. I get back the info fine and it prints it the way it
looks like when telnetting through an emulator. But when I save it to a
list and try to pattern mach on each line it failes. The reason for it
seems to be everything being returned is in one big line. So a $#variable
returns 1 as the length of the screen. Here is how I store the value to

after the information I need. Any ideas?


Tue, 10 Apr 2001 03:00:00 GMT  
 Net::Telnet - problem with \n characters

Quote:

> The reason for it seems to be everything being returned is in one
> big line. So a $#variable returns 1 as the length of the
> screen. Here is how I store the value to the list

> after the information I need. Any ideas?

waitfor() in a list context returns two values when successful -
prematch and match.  In your example match will always be 'VAN' and
prematch will contain the info you want.

To find the line before 'VAN' you can either split prematch on "\n"

    ($prematch, $match) = $objRAS->waitfor('/VAN/');

    $prevline = $lines[-1];

or you can read using getline() and then check each line for 'VAN'.

    while ($line = $objRAS->getline) {
        last if $line =~ /VAN/;

        $prevline = $line;
    }

--
Jay Rogers



Sat, 14 Apr 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Net::Telnet-ing problem to Solaris telnet server

2. Net::Telnet 80 Character truncation

3. Net::Telnet - Junk Characters.

4. Net::Telnet - sending special characters

5. using Net::Telnet without escape characters

6. Net::Telnet 3.03: drain a telnet buffer

7. Telnet-Client with Net::Telnet

8. Telnet cmd, Net::Telnet

9. keeping Telnet alive with Net::Telnet

10. Net::Telnet -like module without telnet

11. Net::Telnet problem

12. Suspected problem with Net::Telnet module

 

 
Powered by phpBB® Forum Software