Click here to get back home

Net::Telnet retrieving temporary text problem

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::Telnet retrieving temporary text problem pdc124 11-06-2006
Posted by pdc124 on November 6, 2006, 3:32 am
Please log in for more thread options


Im retrieving screens of information from a telnet server, going
(backwards) from one to the next by pressing '0'. When I get to the
first one a message 'No more previous attendances' flashes on the
screen .
thuis retrieves the screens
($names)=$t2->waitfor('/Main Index Details/');
print $names;print $q-> hr;
do
{$t2->print('0');

my ($names2)=$t2->waitfor('/Main Index Details/');
$names=$names.$names2;
print $names;print $q-> hr;
}

until ($names=~/No\s+more/);

'No more previous' appears in dump_file and input_string but not in
$names;

Version 2 generates an error
Can't "last" outside a loop block at /var/www/localhost/cgi-bin/pas2.pl
line 119.

my $last=0;
do
{$t2->print('0');
$text='';
do {$text=$t2->get;
#print $text;print $q-> hr;##debugging string
        if ($text=~m/previous/)
$names.=$text;}
until ($text=~m/Delete/);
}
until ($last);
print $names;print $q-> hr;

so how do i exit the loops when it finds the text ?


Posted by John W. Krahn on November 6, 2006, 4:45 am
Please log in for more thread options


pdc124 wrote:
> Im retrieving screens of information from a telnet server, going
> (backwards) from one to the next by pressing '0'. When I get to the
> first one a message 'No more previous attendances' flashes on the
> screen .
> thuis retrieves the screens
> ($names)=$t2->waitfor('/Main Index Details/');
> print $names;print $q-> hr;
> do
> {$t2->print('0');
>
> my ($names2)=$t2->waitfor('/Main Index Details/');
> $names=$names.$names2;
> print $names;print $q-> hr;
> }
>
> until ($names=~/No\s+more/);
>
> 'No more previous' appears in dump_file and input_string but not in
> $names;
>
> Version 2 generates an error
> Can't "last" outside a loop block at /var/www/localhost/cgi-bin/pas2.pl
> line 119.
>
> my $last=0;
> do
> {$t2->print('0');
> $text='';
> do {$text=$t2->get;
> #print $text;print $q-> hr;##debugging string
>         if ($text=~m/previous/)
> $names.=$text;}
> until ($text=~m/Delete/);
> }
> until ($last);
> print $names;print $q-> hr;
>
> so how do i exit the loops when it finds the text ?

See the end of the "Statement Modifiers" section of perlsyn for a solution:

perldoc perlsyn



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall

Posted by pdc124 on November 6, 2006, 5:17 am
Please log in for more thread options


thanks .
its breaking out of 2 do loops that im not getting correct

my $last=0;
LOOP: do
{$t2->print('0');
$text='';
do {$text=$t2->get;# print $text;print $q-> hr;
last if ($text=~m/previous/);#        if
($text=~m/previous/)
$names.=$text;
                 }
until ($text=~m/Delete/); #until ($last);#print $names;print $q->
hr;print $q-> hr;
}
#until ($last);
print $names;print $q-> hr; ##this is line 122

Software error:
syntax error at /var/www/localhost/cgi-bin/pas2.pl line 122, near
"print"

ie I assume it needs an 'until' to go with the do

but then removing the do and just leaving the curly braces doesnt
execute the loop

LOOP:
# do
{$t2->print('0');
$text='';
do
{$text=$t2->get; print $text;print $q-> hr;
last if ($text=~m/previous/);#
$names.=$text;
        }
until ($text=~m/Delete/);
}
#until ($last);
print $names;print $q-> hr;

sends no '0's and doesnt grab any other screens of information


Similar ThreadsPosted
How to open temporary with Perl 5.6? September 24, 2007, 12:28 pm
net::telnet problem July 23, 2004, 6:46 pm
Problem with Net::Telnet October 20, 2005, 4:19 pm
Telnet Problem December 8, 2006, 5:06 am
Net:Telnet problem with print October 20, 2005, 5:04 pm
problem in telnet using perl December 27, 2007, 11:22 pm
Telnet problem -getting timed out error - April 18, 2006, 9:15 am
reading from Net::Telnet input string problem June 16, 2006, 1:17 pm
Problem with body text extraction with HTML::Parser December 13, 2005, 3:28 pm
Retrieving information from website July 28, 2006, 4:47 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap