develooper Front page | perl.beginners | Postings from March 2002

Re: time limit???

Thread Previous | Thread Next
Peter Scott
March 29, 2002 11:54
Re: time limit???
Message ID:
At 12:50 PM 3/29/02 -0500, Alberto Santana wrote:
>Hi guys,
>Suppose I have a Perl script (called from a crontab file) that will,
>basically, do something like this:
>$out=`lynx -dump`;
>print OUT $out;
>$send_it=`mail me\<out`;
>OK, here comes the problem. What if the web page is down? lynx will
>keep trying for a while until it gives up or something.
>Is it possible to impose a time limit, like: execute $out, wait for
>45 seconds, if there was no response (lynx did not dump), exit(0);


use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
my $res = $ua->request(GET 
if ($res->is_success) {
   require Mail::Send;
   my $msg = Mail::Send->new;
   my $fh = $msg->open;
   print $fh $res->content;

Peter Scott
Pacific Systems Design Technologies

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About