[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] testing for net connectivity





##  Hi Scott,
##                in order to KNOW IT just TEST IT:

use LWP::Simple;

if (get("http://www.MyOwnDomain.com/MyFile.html")  {
   print "The Internet line \nseems to be fine."   }
else  {
   print "Plight forgotten: \nthe line is rotten."  }

## On your own site  (or on the site you want to see if
##  the line is working) install an arbitrary (maybe
very short)
##  file, e.g. MyFile.html. In case this file is found by
##  the function "get" from LWP::Simple (see Perl Cookbook,
##   p. 708) "get" returns the contence, resulting in
the logical
##  value of "true".
##  - - - I did not test this -- hope it works.

##  Detlef Lindenthal <detlef@lindenthal.com>




__END__

"Scott R. Godin" wrote:

> How would I program MacPerl to test for whether or not I have a working
> internet connection before performing other tasks .. I'd like it to die more
> gracefully if possible :)

> being on a flaky dialup instead of the cool cable/dsl solutions, makes this
> a near necessity if I want to run timed regular scripts.

> --
> Scott R. Godin            | e-mail : webmaster@webdragon.net
> Laughing Dragon Services  |    web : http://www.webdragon.net/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org