LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-21-2010, 12:39 PM   #1
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Rep: Reputation: 18
Setting Headers for Web Pages in Perl


There is an AIX 5.3 Box and there are some Perl scripts that generate web pages. We use them for monitoring of logs. But the perl script, let's name it "displayLogStatus.pl", that extracts some information such as "Failed", or "Completed" from specified log files doesn't refresh the page automatically.

In PHP I know how to refresh / reload a page after a specific time interval. For example this command in a web page:

PHP Code:
header("refresh:60"); 
would refresh the web page every 1 minute automatically.

How do we do that in Perl?
 
Old 09-21-2010, 01:08 PM   #2
jangovich
LQ Newbie
 
Registered: Sep 2010
Location: Mississauga, Ontario
Distribution: Ubuntu 10.04
Posts: 21

Rep: Reputation: 5
Have you tried this:

Code:
#!/usr/bin/perl
print "Refresh: 10; url=http://www.example.com/\r\n";
print "Content-type: text/html\r\n";
print "\r\n";
Before any other contents gets printed out?
 
1 members found this post helpful.
Old 09-21-2010, 02:14 PM   #3
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Original Poster
Rep: Reputation: 18
Refreshing a Web Page in Perl

Quote:
Originally Posted by jangovich View Post
Have you tried this:

Code:
#!/usr/bin/perl
print "Refresh: 10; url=http://www.example.com/\r\n";
print "Content-type: text/html\r\n";
print "\r\n";
Before any other contents gets printed out?

Okay, here it is as suggested by you:

Code:
-bash-2.05b# cat sample.pl
#!/usr/bin/perl
print "Refresh: 10;\r\n";
print "Content-type: text/html\r\n";
print "\r\n";
print "This page refreshes every 10 seconds.\r\n";
open(DAT, "/tmp/sample.log") || die("Could not open the file: /tmp/sample.log");
@raw_data=<DAT>;
close(DAT);

print "<pre>";
foreach $everyLine (@raw_data) {
        print $everyLine;
}
print "</pre>";
-bash-2.05b#
Now let's try this:

Code:
-bash-2.05b# cal > /tmp/sample.log
-bash-2.05b# cal 2010 > /tmp/sample.log

We don't need to refresh the web page manually. It does it for us!

So, what is your fee? Haha!!!

Thanks a lot!
 
  


Reply

Tags
auto, header, perl, refresh, time


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web server sees the pages, but not the folder that has all the images for the pages nortonz Linux - Server 9 05-17-2010 04:04 PM
MS Publisher html pages for new web pages do not open in firefox, any suggestions?? Bwebman Linux - Newbie 3 06-13-2009 11:35 AM
ADSL Router Web configuration pages appears instead of Personal Web Server Pages procyon Linux - Networking 4 12-20-2004 06:44 PM
hosed perl - missing various perl headers suffer Slackware 4 11-14-2003 09:35 AM
Can't access Linux web server web pages from LAN client jaydave Linux - Networking 4 03-16-2003 03:38 AM


All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration