Solved

View a log file at 50 lines at a time.

Posted on 1998-01-09
11
184 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
Comment Utility
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
Comment Utility
where do i put the file name?
0
 
LVL 1

Expert Comment

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

while( <FILE> )
{

...
0
 

Author Comment

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

Author Comment

by:Perl_Man
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
Comment Utility
fix that pert, but still coming up with an internal server error message.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
fixed it
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

6 Experts available now in Live!

Get 1:1 Help Now