|
I have a routine that saves a backup copy of a url using the LWP module. It works reliably on Windows servers. I have just set up a machine with the J2EE environment and Tomcat web server, and the routine will not run through the server on this machine (although it will run from the command prompt). I presume this means that the problem is somewhere in the server setup or permissions, but I can’t seem to locate anything that resolves the problem. I need to get this working through the browser because it is part of a web-based system. Any suggestions on what needs tweaked?
Here is an abbreviated copy of the code: sub CheckSave{ my $id = $_[0]; #passing primary key my $url = "" #whether or not to save backup my $savepath = $_[2];
#check web page header to see if it exists @dat=head($url); if ([EMAIL PROTECTED]) { print <<EOF; <DIV STYLE="color:red;border:solid 2px red; padding:4px;"> System cannot contact the Internet to save a backup. Please contact the webmaster or edit the web address entered.<BR> URL: $url </DIV> EOF ; die; }
#get extension for saved file from url $ext=$in{"cec_url"}; if ($ext =~ /\?/ || $ext =~ /.com$/) { #if url contains a query string, use header to return extension #if .com address, use content_type $ext=$dat[0]; $ext =~ s/.*\/(.*)/\1/; } else { #otherwise, find the file type from the url $ext =~ s/.*\.([^\/]*)/\1/; }
#save the new web download $saveFile = $savepath.$id.".".$ext; #generate archive file name $status = getstore($in{"cec_url"}, $saveFile); #check url and save copy
if (is_success($status)) { print qq[<BR><CENTER>Backup copy saved.</CENTER>\n]; } else { #print warning if website was not valid print <<EOF; <DIV STYLE="color:red;border:solid 2px red; "> Website link not found. Archive file not saved.<BR> Please edit this record. </DIV> EOF ;
} } |
_______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
