Assistance with Perl and HTTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Assistance with Perl and HTTP
# 1  
Old 12-08-2006
Assistance with Perl and HTTP

I need to query a http site and then parse the xml results, this works well if I use the string in IE but I require an automated solution.

I have tried using the following as well as HTTP::Request, nothing seems to work any suggestions would be appreciated, I have tried diffrnt things I found on the site but it seems as though I can't connect even though I can from IE.
<begin>
use LWP::Simple;
$content = getprint("http://www.web.com/feeds/val.php?vid=val&pw=val&op=val&reporttype=val&qp=val");
die "Couldn't get it!" unless defined $content;
<End>
# 2  
Old 12-08-2006
Code:
tyler@mecgentoo ~ $ perldoc -f getprint
No documentation for perl function `getprint' found
tyler@mecgentoo ~ $

I love the perl help system.

Have you tried downloading the page with wget? The page might block anything that's not IE or Firefox.
# 3  
Old 12-09-2006
What exactly is not working in your case? Did you examine the error code? You can also put in tcpdump to examine the http request-response pair to check what is happening.

Quote:
Originally Posted by Corona688
Code:
tyler@mecgentoo ~ $ perldoc -f getprint
No documentation for perl function `getprint' found
tyler@mecgentoo ~ $

I love the perl help system.
Corona688,

The getprint() is actually a static method of LWP::Simple that is exported to the function namespace using the Exporter module. Therefore, you don't need to qualify with the module name. It is not an intrinsic function but can be called like a function if LWP::Simple is loaded.

Last edited by cbkihong; 12-09-2006 at 03:05 AM..
# 4  
Old 12-09-2006
By the way, according to the LWP::Simple manpage, the return value of getprint() is the HTTP status code. The HTTP response is sent to STDOUT. If you want to get the response in a string, you have multiple methods:

1. Use get() instead of getprint().
2. Use the full-featued LWP instead of LWP::Simple.
3. Perform output buffering and capture the STDOUT in a scalar variable.

e.g.

Code:
my $content;
{
    local *STDOUT;
    open(STDOUT, '>', \$content);
    $status = getprint("http://www.google.com");
}
# $status contains HTTP status code
# $content contains HTTP response

# 5  
Old 12-11-2006
I am getting a 500 Can't connect to www.google.com:80 (Connect: Unknown error) < URL:Http://www.google.com>
# 6  
Old 12-11-2006
Are you on a peculiar Windows security configuration set by your network administrator that only IE works? It all works fine for me. Or check whether you have a firewall e.g. ZoneAlarm that blocks all network connections except those initiated by applications you have previously agreed to.

If everything fails, check the packets by tcpdump then. I am inclined to think it is not a problem of LWP::Simple or Perl.
# 7  
Old 12-11-2006
The only thing I can think of is IE is aware of our proxy and the perl isn't, Can you specify a proxy in Perl?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assistance on complicated perl script

As a followup to my previous thread, I'm trying to make a complicated perl script that involves storing information from a text file into a hash, and giving the user the ability to change the information present/write the information currently inside the hash to a new file. This is the code I've... (8 Replies)
Discussion started by: Eric1
8 Replies

2. Shell Programming and Scripting

Perl HTTP::Tiny

I'm currently using OpenBSD current as of yesterday. Both curl and wget aren't not part of the OpenBSD base and I would rather attempt to reboot my cable modem (SB6183) using perl HTTP:Tiny if possible. The following 2 commands work and both will reboot my modem: curl -d Rebooting=1... (3 Replies)
Discussion started by: azdps
3 Replies

3. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

4. Shell Programming and Scripting

Perl Http Post over SSL

Hello, I'm using a tunnel broker for tunneling IPv6 traffic, as my ISP does not support it natively. As of recent i switched from Hurricane Electrics tunnel broker to Sixxs. Whenever my IP address changes, i have to manually log in and change it. This is a bit cumbersome so i was thinking of... (0 Replies)
Discussion started by: regexp
0 Replies

5. Shell Programming and Scripting

sending http url through http socket programming..

hi am senthil am developing a software to send and receive SMS using HTTP connection first of all am forming a URL and sending that URL to a remote server using my Client Program i send that url through Socket(using Send() Function) if i send more than one URL one by one using the same... (4 Replies)
Discussion started by: senkerth
4 Replies

6. Shell Programming and Scripting

awk, sed, perl assistance in outputting formatted file

Hello, Please advise. Scoured this site, as well as google for answers. However if you do not know what to search for, it's a bit hard to find answers. INPUT: ACTASS= 802 BASECOS= 279 COSNCHG= 3 CUSCOS= 52 UPLDCOS= 2 DESIRED OUTPUT: ACTASS=802 BASECOS=279 (13 Replies)
Discussion started by: abacus
13 Replies

7. Shell Programming and Scripting

Assistance in Perl scripting

PFA file "color.txt". Note : There is no newline character in the file. I have manually inserted the newline char to make it easy to understand. I am expecting out in the form as specified in second file "out.txt" I need a perl script to perform the task. Thanks in advance. (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

8. Shell Programming and Scripting

Assistance needed with perl script

Ok, theres a log file containing the below. Lets call the logfile log_fantastic: 2009/03/16 21:42:45 USER: tonnabo - MAC: 0014BF2D385A - STATUS_ID: 30 - STATE: ERROR 2009/03/16 21:42:45 USER: tonnabo - MAC: 001310AC120D - STATUS_ID: 15 - STATE: OK 2009/03/16 21:42:45 USER: tonnabo - MAC:... (5 Replies)
Discussion started by: SkySmart
5 Replies

9. Shell Programming and Scripting

In need of multi threaded perl assistance

I need to write a perl script to execute external programs and grab the output and return code. Each program should be killed if it has not completed within X seconds. Imagine that the script goes something like this : @commands = &get_commands(); foreach $cmd (@commands) { $pid =... (4 Replies)
Discussion started by: SandmanCL
4 Replies

10. Shell Programming and Scripting

Perl script assistance; paste word into external command

I'm attempting to create a Perl script that will: Take the contents of the usernames.tmp file (usernames.tmp is created from an awk one-liner ran against /etc/passwd) Take one line at a time and pass it to the su command as a users name. This should go on until there is no more name to... (10 Replies)
Discussion started by: bru
10 Replies
Login or Register to Ask a Question