Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

URL post

by Anonymous Monk
on Aug 18, 2003 at 22:52 UTC ( [id://284751]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://284751]
Approved by gjb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-25 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found