Displaying text file in browser - perl

Don't know why this didn't get posted before but...

I am having issues displaying a log file in the browser using perl and I can't get it to display at all, All i get is WHITE (blank page). I have proper permissions in my cgi-bin directory and everywhere else. So I know that's NOT the issue. Also when I try to manually run the script from console , it spits out the contents of the file just fine.

Here is snippet of my code:

#!/usr/bin/perl

print "content-type: text/html \n\n";

open (FH , "access.log") || die "Blah $!";

while (<FH>) {
        print $_ ;
}
close (FH);

Here is the contents of the log file..its just access.log file.

1219582729.698    133 24.130.155.89 TCP_MISS/200 1496 POST http://ocsp.thawte.com/ gsingh DIRECT/199.7.54.72 application/ocsp-resp
onse
1219582730.138     53 24.130.155.89 TCP_MISS/200 1496 POST http://ocsp.thawte.com/ gsingh DIRECT/199.7.54.72 application/ocsp-resp
onse
1219582730.512     81 24.130.155.89 TCP_MISS/200 1891 POST http://ocsp.thawte.com/ gsingh DIRECT/199.7.54.72 application/ocsp-resp
onse
1219582791.993  59571 24.130.155.89 TCP_MISS/200 1712 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.19 -
1219582793.002  60565 24.130.155.89 TCP_MISS/200 1704 CONNECT www.google.com:443 gsingh DIRECT/74.125.19.103 -
1219582793.043  60608 24.130.155.89 TCP_MISS/200 4695 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.17 -
1219582793.135  60725 24.130.155.89 TCP_MISS/200 2976 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.17 -
1219582793.180  63199 24.130.155.89 TCP_MISS/200 17672 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.18 -
1219582793.217  60788 24.130.155.89 TCP_MISS/200 4252 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.83 -
1219582793.228  60399 24.130.155.89 TCP_MISS/200 1899 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.19 -
1219582793.333  60480 24.130.155.89 TCP_MISS/200 1762 CONNECT mail.google.com:443 gsingh DIRECT/74.125.19.83 -

Any help is highly appreciated :slight_smile:

Thanks

You are not writing a valid HTML page. At a minimum you need the following layout

<html>
   <head></head>
   <body>
    ----------- your log file data here ........ 
   </body>
</html>

Neither is that a valid HTML page. The HTML, HEAD and BODY tags, both opening and closing, are optional.

What is required is a doctype, a title, and a block element. This is a valid HTML page:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
  <title></title>
  <p>

The OP should check the logs to see whether any errors were generated.

Also, check the permissions on the script (remove group write permission).

Figured out my answer... finally

so in the console it was working fine but not in web browser..hmm
It was permission issue :frowning:

The permission issue was on the log file ...dohh :frowning: I should've checked the perms on the file too ..my bad.

Thx group.