Displaying text file in browser - perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying text file in browser - perl
# 1  
Old 12-11-2008
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:

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.

Code:
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 Smilie

Thanks
# 2  
Old 12-11-2008
You are not writing a valid HTML page. At a minimum you need the following layout
Code:
<html>
   <head></head>
   <body>
    ----------- your log file data here ........ 
   </body>
</html>

# 3  
Old 12-11-2008

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:

Code:
<!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).
# 4  
Old 12-11-2008
Figured out my answer... finally

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

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

Thx group.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with text modification and displaying

I have a file storing some text and another file storing some numbers I want to display characters other than the specified place of strings one.txt xyz abc 233 skfo 4r443 sfs abc abcd sd fsdf sdfd abc 11 abc 33 abc dsaf two.txt Nt_djd_k='5-6,7-9' Nt_hh_l='3-6,7-8' a=`grep... (4 Replies)
Discussion started by: rahulsk
4 Replies

2. Shell Programming and Scripting

Displaying certain text in a msg.

I have a requirement to display a part of an html response that my application gets. The response looks like this: <html><a href='com.aprisma.spectrum.app.sd.client.SDHyperlinkHandler' sdTicketHandle='cr:419900' ocAlarmId='506618ea-f013-102d-02a7-0050569d7aa8'... (3 Replies)
Discussion started by: dlundwall
3 Replies

3. Shell Programming and Scripting

Displaying a number in binary using perl

printf FH2" 3'b%b : begin\n",$i; where i is an integer in the loop is displaying 3'b1 : begin expected output was 3'b001 : begin (1 Reply)
Discussion started by: dll_fpga
1 Replies

4. Web Development

Too long in displaying the data in a Web Browser

this is my another one question as well as my sample program. Because of the big data the gets from the database.,it takes time to display the output in a web browser.,is there any way to display the output as faster as it can..?my time is wasting because of too long to display.:confused: ... (3 Replies)
Discussion started by: Jeneca
3 Replies

5. Shell Programming and Scripting

Displaying Result to a Text File

Hi; I am scripting in Shell and i want to write output (on screen) to a text file? ... | tee gcsw/output.txt doesnot work? :(:( (6 Replies)
Discussion started by: gc_sw
6 Replies

6. UNIX for Dummies Questions & Answers

How can I append a text at end of file after displaying the file

I have a file "sample.txt" with the content as below: Hi This is a Sample Text. I need a single command using cat which serve the following purpose. 1.display the contents of sample.txt 2.append some text to it 3. and then exit But, all should be served by a sinle command.:confused: (1 Reply)
Discussion started by: g.ashok
1 Replies

7. UNIX for Dummies Questions & Answers

Displaying Text

Hi guys! I am very much new to UNIX...and I was just wondering on how you would display this text format in UNIX with only just one command : Text 1 Text 2 Text 3 Texts are in aligned vertically in such format...Thanks for your help :) (8 Replies)
Discussion started by: Knowledge_Xfer
8 Replies

8. Shell Programming and Scripting

Displaying text file in browser - perl

I am having issue dispalying text file in browser using perl. Here is my code: #!/usr/bin/perl print "content-type: text/html \n\n"; open (FH , "access.log") || die "Blah $!"; while (<FH>) { print $_ ; } I have correct permissions and everything. The weired thing is when I... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

9. UNIX for Advanced & Expert Users

script to open the specified url in a browser from a text file

Hi All, here i am struc (6 Replies)
Discussion started by: gsp
6 Replies

10. UNIX for Dummies Questions & Answers

Text-based internet browser?

Dear all, I can only use text-based terminal, x-window is not support my session. Do anyone know have any text-based Internet browser in Sparc sun? Regards Wilson (2 Replies)
Discussion started by: wilsonchan1000
2 Replies
Login or Register to Ask a Question