tame1 has asked for the wisdom of the Perl Monks concerning the following question:

I want to design a small system whereby a cron job will call my script,
which will test to ensure proper ops of the web server and
other various daemons. If there is a problem, I want it to page me.

The paging part is the problem. I need to hit a cgi script on
the ameritech web site, along with values for the form fields
that normally feed it. I have never messed with calling up
foreign web pages, etc. from within a script. Also, I would need
the script to pass through the firewall, using my userid and pass.

Can anyone show me how to hit a foreign URL, with values in the URL
of course, or tell me a better way? NOTE: The return response from the ameritech server
need not be parsed, I think.

What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"

Replies are listed 'Best First'.
Re: Hitting a web page
by kilinrax (Deacon) on Nov 29, 2000 at 21:36 UTC
    Use LWP::UserAgent.
    #!/usr/bin/perl -w use strict; use LWP::UserAgent; use URI::URL; my $ua = new LWP::UserAgent; my $uri = new URI::URL "http://www.perlmonks.org"; $uri->query_form("node_id" => "43958"); my $req = new HTTP::Request GET => $uri->as_string; my $res = $ua->request($req); if (!$res->is_success) { die 'Fetch failed'; } my $content = $res->content; print $content;
      This seems to have worked, with some exceptions. (BTW - thanks!)

      I added $ua->proxy(['http','ftp'],'http://my.proxyserver.com:83');
      The only problem seems to be that my proxy requires a password, and
      reading throuhg perldoc LWP::UserAgent, I cannot find how I am
      supposed to pass the username and pass that the proxy server
      requires! I see how to pass them if the remote server needs them,
      but not the proxy ones.

      Are you at all familiar with this?

      What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"
        See RE: Getting a webpage through proxy, which has the following code:
        use LWP::UserAgent; #..... usual stuff .....# $ua = new LWP::UserAgent; $ua->proxy(['http', 'ftp'] => 'http://your_proxy.address.com:'); my $req = new HTTP::Request 'GET', "http://www.perlmonks.org"; $req->proxy_authorization_basic("$user_name","$user_password"); $res = $ua->request($req);

        (Obtained through Super Search for "LWP proxy password". Super Search is also your friend!)

      Disregard my last - I did some searching on the links that
      one of the other responders had posted (thanks folks) and
      discovered $req->proxy_authorization_basic

      Again, thanks everyone.

      What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"
Re: Hitting a web page
by swiftone (Curate) on Nov 29, 2000 at 21:47 UTC
Re: Hitting a web page
by davorg (Chancellor) on Nov 29, 2000 at 21:37 UTC

    For making a CGI request you need to look at the LWP bundle of modules from CPAN.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me