Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > script for http request

Reply
Thread Tools

script for http request

 
 
RogerF
Guest
Posts: n/a
 
      02-15-2007
Hello... don't do alot of perl scripting so I am not well experienced
with scripting...

I want to return the values from a simple http request in a perl
script.

So for example, if I have a http request on a server such as:

http://<server>/servlet/inbasket?RDUSER=pfuser&FUNCTION=gettasks

And the return of the URL is:

<?xml version="1.0" ?>
- <INBASKET>
<USERTASKS userid="" returnmsg="No tasks set up for workflow user
pfuser" msgtype="Error" />
</INBASKET>

I want to take the returnmsg value ("No tasks set up for workflow user
pfuser") from the request and send it to an email recipient.

Just looking for the syntax of the Http request and how to get the
return values

require HTTP::Request;
$request = HTTP::Request->new(GET => 'http://<server>/servlet/inbasket?
RDUSER=pfuser&FUNCTION=gettasks');
....
....
....
$response = $ua->request($request)
if ($response->is_success) {
print $response->content;
}
else {
print STDERR $response->status_line, "\n";
************************************************** ******************

So how do I get the value of returnmsg??? Can I somehow parse out
'content'??

Needing just a little help to get this syntax correct.

Thanks in advance for your assistance.

-Roger

 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      02-15-2007
RogerF wrote:
[...]
> So for example, if I have a http request on a server such as:
>
> http://<server>/servlet/inbasket?RDUSER=pfuser&FUNCTION=gettasks
>
> And the return of the URL is:
>
> <?xml version="1.0" ?>
> - <INBASKET>
> <USERTASKS userid="" returnmsg="No tasks set up for workflow user
> pfuser" msgtype="Error" />
> </INBASKET>

[...]
> So how do I get the value of returnmsg??? Can I somehow parse out
> 'content'??
>
> Needing just a little help to get this syntax correct.
>
> Thanks in advance for your assistance.


It's XML, of course it can be parsed. Take a look at XML::Simple, on
CPAN (http://search.cpan.org/)
 
Reply With Quote
 
 
 
 
gf
Guest
Posts: n/a
 
      02-15-2007
On Feb 15, 8:39 am, "RogerF" <(E-Mail Removed)> wrote:
> Hello... don't do alot of perl scripting so I am not well experienced
> with scripting...
>
> I want to return the values from a simple http request in a perl
> script.
>
> So for example, if I have a http request on a server such as:
>
> http://<server>/servlet/inbasket?RDUSER=pfuser&FUNCTION=gettasks
>
> And the return of the URL is:
>
> <?xml version="1.0" ?>
> - <INBASKET>
> <USERTASKS userid="" returnmsg="No tasks set up for workflow user
> pfuser" msgtype="Error" />
> </INBASKET>
>
> I want to take the returnmsg value ("No tasks set up for workflow user
> pfuser") from the request and send it to an email recipient.
>
> Just looking for the syntax of the Http request and how to get the
> return values
>
> require HTTP::Request;
> $request = HTTP::Request->new(GET => 'http://<server>/servlet/inbasket?
> RDUSER=pfuser&FUNCTION=gettasks');
> ...
> ...
> ...
> $response = $ua->request($request)
> if ($response->is_success) {
> print $response->content;
> }
> else {
> print STDERR $response->status_line, "\n";
> ************************************************** ******************


Just addressing your HTTP request...

If all you are doing is making a simple request and not needing a lot
of control over how LWP behaves, then use LWP::Simple.

Then your request becomes a simple get('url') call, which returns
whatever the server sent.

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      02-15-2007
gf wrote:

> Just addressing your HTTP request...
>
> If all you are doing is making a simple request and not needing a lot
> of control over how LWP behaves, then use LWP::Simple.
>
> Then your request becomes a simple get('url') call, which returns
> whatever the server sent.



Minus the headers.


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
gf
Guest
Posts: n/a
 
      02-15-2007
On Feb 15, 10:56 am, Brian Wakem <(E-Mail Removed)> wrote:

> Minus the headers.


Correct, but sometimes that's desirable.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Abort an HTTP request before the request timed out Gelonida N Python 0 02-27-2012 02:22 AM
urllib2.Request:: http Request sending successfully, but Responsecontains in valid data. nRk Python 1 02-12-2009 12:53 AM
Why getInputStream in a http servlet request isn't getting the datasent by browser HTTP POST action? James Java 3 11-25-2005 11:17 PM
How to enter to .aspx page by http connection using http POST request farazkazmi@gmail.com Java 6 08-29-2005 02:58 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments