script for http request

R

RogerF

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
 
J

J. Gleixner

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/)
 
G

gf

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.
 
B

Brian Wakem

gf said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,103
Latest member
VinaykumarnNevatia
Top