Can Perl refresh a page?

Hello,

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

Regards,
ak
akohanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.