Solved

View a log file at 50 lines at a time.

Posted on 1998-01-09
11
186 Views
Last Modified: 2008-03-06
I know this is almost the same as the question about 700 lines, but I would like someone to help me have it do more. How do I have it load 50 lines of a document, have it create a button (submit) that I could click on then it load the next 50, and so on and so on.

thanks
0
Comment
Question by:Perl_Man
  • 6
  • 3
  • 2
11 Comments
 
LVL 1

Accepted Solution

by:
malec earned 10 total points
ID: 1209528
same thing (almost):

while( <FILE> ){
   push @a,$_;
   next if @a < 50;
#process your 50 lines here

   print <TT;
     <form method="POST">
     <input type="submit" value="Next 50 lines"
     </form>
TT

   @a = ();
  }
  do the rest here
0
 

Author Comment

by:Perl_Man
ID: 1209529
where do i put the file name?
0
 
LVL 1

Expert Comment

by:malec
ID: 1209530
open (FILE, "/usr/people/myfile") || die "Cannot open $!";

while( <FILE> )
{

...
0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

Author Comment

by:Perl_Man
ID: 1209531
thanks, let me test it out.  then if it works u get the credits.
0
 

Author Comment

by:Perl_Man
ID: 1209532
this is what I have on my site and it gives me an 500 Internal Server Error message (from my browser....

if ($command eq 'ViewFullLog') {
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head><title>View the log</title></head>\n";
print "$body\n";

open (FILE, "/cgi-bin/FullLog.txt") || die "Cannot open $!";
while( <FILE> ){
      push @a,$_;
        next if @a < 50;
        #process your 50 lines here
        print <TT;
              <form method="POST">
              <input type="submit" value="Next 50 lines"
              </form>
        TT
      print "</body></html>\n";
        @a = ();

exit;
}
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209533
print <TT;
should be
 print <<TT;
and the coreesponding TT at the end should be the onle thing on the line
with no blank spaces before or after it.

0
 

Author Comment

by:Perl_Man
ID: 1209534
fix that pert, but still coming up with an internal server error message.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209535
Does it get the same error when $command ne 'ViewFullLog'?
Do you have a close } on your if?
What's in $body?
What if you change
  die "Cannot open $!"
to
  print "Content-type text/plain\n\nCannot open $!\n</body></html>\n"

and
 <input type="submit" value="Next 50 lines"
should probably be
 <input type="submit" value="Next 50 lines">
0
 

Author Comment

by:Perl_Man
ID: 1209536
Ok $body holds the <body bg=.... text=.... etc.> i know that is  not the problem since it works fine in all of my other scripts and it worked fine before I added this code.  Also I tried change eq, still made no difference (so I changed it back).  I fixed the form error (missing the >). Still no difference.  Also changed the content-type command.  Still no change, still gettign the Internal Server Error..
0
 
LVL 1

Expert Comment

by:malec
ID: 1209537
Are there any print statements before that code fragment? If there are they should be preceded by print "Content-type: text/html\n\n", which should be your first print.
0
 

Author Comment

by:Perl_Man
ID: 1209538
fixed it
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
use perl to insert into MySQL database 9 138
Awk Question 2 127
batch script for automated email 12 111
Perl Application JSON Receiving Strange Java Error 3 70
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question