Solved

View a log file at 50 lines at a time.

Posted on 1998-01-09
11
185 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now