[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1254
  • Last Modified:

Can Perl refresh a page?

Hello,

I need to refresh a page from crontab. Can I use Perl if so then how?

Regards,
ak
0
akohan
Asked:
akohan
  • 2
  • 2
1 Solution
 
Adam314Commented:
Is this related to: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23117283.html

You can have a perl script update a page from crontab.  Add this to your crontab:
*/10 * * * * /path/to/perl/script
(for every 10 minutes)

What is in the perl script will depend on exactly how you want the page updated.  Something like this:
#!/usr/bin/perl
use strict;
use HTML::Template;
 
my $t = HTML::Template->new(filename => 'index.tmpl');
$t->param(time=>localtime());
open(OUT,">index.php") or die "could not open index.php: $!\n";
print OUT $t->output();
close(OUT);

Open in new window

0
 
akohanAuthor Commented:

Yes, it is the same quesiton and now I found you have answered it using JavaScript.  But I first rather go with this solution (perl) since I'm using index.php on a server which is pretty restricted and even some javascript methods are blocked.

One thing that I have never done Perl and I got the following message which I ran above code:

Can't locate HTML/Template.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at update.pl line 3.
BEGIN failed--compilation aborted at update.pl line 3.

Any idea where I went wrong?

Regards,
ak

0
 
Adam314Commented:
The perl code will update the index.php file on the server - not cause the page to be refreshed in the browser.
The javascript in your other question will cause the page to be refreshed in the browser - not update the page on the server.

Which you use will depend on what you are trying to do.

The above error is telling you that the HTML::Template module is not installed.  If you want to have the perl script update the index.php page on the server, the code I gave is an example of a way to do that.  You will need to install the HTML::Template module.  From a prompt:  
    perl -MCPAN -e 'install HTML::Template'
0
 
akohanAuthor Commented:

Thanks for your help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now