http://qs1969.pair.com?node_id=284751

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

Hi.
I am seeking some help with a script that triggers a script on a server to begin a process.

I have no great experience as perl expert. Here is what I have:

use HTTP::Request; use LWP::UserAgent; # Variables # my $url = "http://somedomain.com/cgi-bin/somescript.cgi?variouscharact +ers"; my $ua = new LWP::UserAgent; my $res = $ua->request(POST $url); if ($res->success) { print $res->content || die "Not possible\n"; }
Thanks for any and all help.
-james

edited by ybiC: balanced <code> tags

Replies are listed 'Best First'.
Re: URL post
by arthas (Hermit) on Aug 18, 2003 at 23:24 UTC

    Hi!

    The script has some errors. Here's a fixed version:

    use HTTP::Request; use LWP::UserAgent; my $url = "http://somedomain.com/cgi-bin/somescript.cgi?variouscharact +ers"; my $ua = new LWP::UserAgent; my $req = new HTTP::Request(GET => $url); my $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { die "Not possible\n"; }

    Among the other things, you should really use GET as request method for an URL like the one you provided. Also, take a look at the numerous exampels in the LWP documentation, they're very useful.

    Michele.

Re: URL post
by tcf22 (Priest) on Aug 19, 2003 at 00:52 UTC
    CPAN can be very helpful, when it comes to getting examples on how to use modules.

    A simple search for LWP::UserAgent would have shown that you need an HTTP::Request object.

    A post from last week, Where and how to start learning Perl by woolfy, is worth taking a look at. It gives many fine perl resources.