Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP Get

Status
Not open for further replies.

JJ1

Programmer
Apr 19, 2001
104
GB
Hi,

I'm looking for a perl module which can get a file from a remote webserver and load it into an array. The transfer needs to be done using http.

Could anyone point me in the right direction please?

Many thanks,

James.

 
use LWP

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Thank you for the advice Paul.

I have used LWP to get the file and this works well, from the command line. I am now trying to display the file I have retrieved in a browser (using the CGI module).

Unfortunately, I reveive the following message each time:
[red]
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, xxxxx@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log."
[/red]

In the error log I see:
[red]
"[Wed Jun 04 09:15:48 2003] [error] [client 192.168.0.2] (22503)The system cannot find the path specified. : couldn't create child process: 22503: remote.pl
[Wed Jun 04 09:15:48 2003] [error] [client 192.168.0.2] (22503)The system cannot find the path specified. : couldn't spawn child process: C:/apache/cgi-bin/remote.pl"
[/red]

This is my scipt:
[red]
#!F:\Applications\Perl\bin\perl.exe -w

use CGI ':standard';
use LWP::UserAgent;
use strict;

#File to get:
my $url = '
#Frame header
print "Content-type: text/html\n\n";
print <<&quot;HEADER&quot;;
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;<html>
<head></head>
<body>
HEADER

##Get remote file##
#Create a user agent object
my $ua = LWP::UserAgent->new;

#Create a request
my $req = HTTP::Request->new( GET => $url );

#Pass request to the user agent to get webpage
my $response = $ua->request($req);

#Check the outcome of the response
unless ($response->is_success){
print &quot;Could not find the page at $url</body></html>&quot;;
exit;
}

print $response->content;

#Frame Footer
print <<&quot;FOOTER&quot;;
</body>
</html>
FOOTER
[/red]

If anyone can help me with what causes this error (I'm sure it's something simple with my use of CGI) then I would very much appreciate your help.

Many thanks for your time.
Regards,

James.
 
James,

Put in a few print statements to determine where the process is c*apping out. If you can't write them to STDOUT, i.e. the browser page, pass them to a debug log of your own to determine which statement is causing the spawn, and then look at the path therein

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
you might also ...
use CGI::Carp 'fatalsToBrowser';

to dump the errors to the browser...

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top