Solved

View a log file at 50 lines at a time.

Posted on 1998-01-09
11
187 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…

821 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