S
scottny07
I am by no means a perl pro but I am trying to take a url sent from a
form along with a integer and load the given number of URL's to
recache them in our cms system... here is what I have...
#!/usr/local/bin/perl
alarm(300);
use LWP::UserAgent;
use HTTP::Request;
use CGI qw/:all/;
my $query = new CGI;
my $URL = CleanUp($query->param('gURL'));
my $imgCount = CleanUp($query->param('imgCount'));
## Ok, now we can actually begin the refreshing
#
my $orig = $URL;
for(my $i=1; $i <= $imgCount; $i++) {
$URL =~ s/Itemnr=\d*//;
$URL =~ s/&nocache=1//;
$URL = $URL . "&Itemr=$i&nocache=1";
print "Re-Caching image($i) ";
## Here is where we want to authenticate the access to the edit
server
my $ua = LWP::UserAgent->new;
$ua->agent("MyAgent/1.0");
my $req = HTTP::Request->new(GET => $URL);
$req->authorization_basic('user', 'pass');
my $res = $ua->request($req);
my $content = $res;
if ($content) {
print "<a href='$URL' target='_new'><span class='good'>re-cached</
span></a><br />\n";
} else {
print "<a href='$URL' target='_new'><span class='error'><b>re-cach
failed</b></span></a><br />\n";
}
$URL = $orig;
}
exit(0);
Not working... any ideas?
form along with a integer and load the given number of URL's to
recache them in our cms system... here is what I have...
#!/usr/local/bin/perl
alarm(300);
use LWP::UserAgent;
use HTTP::Request;
use CGI qw/:all/;
my $query = new CGI;
my $URL = CleanUp($query->param('gURL'));
my $imgCount = CleanUp($query->param('imgCount'));
## Ok, now we can actually begin the refreshing
#
my $orig = $URL;
for(my $i=1; $i <= $imgCount; $i++) {
$URL =~ s/Itemnr=\d*//;
$URL =~ s/&nocache=1//;
$URL = $URL . "&Itemr=$i&nocache=1";
print "Re-Caching image($i) ";
## Here is where we want to authenticate the access to the edit
server
my $ua = LWP::UserAgent->new;
$ua->agent("MyAgent/1.0");
my $req = HTTP::Request->new(GET => $URL);
$req->authorization_basic('user', 'pass');
my $res = $ua->request($req);
my $content = $res;
if ($content) {
print "<a href='$URL' target='_new'><span class='good'>re-cached</
span></a><br />\n";
} else {
print "<a href='$URL' target='_new'><span class='error'><b>re-cach
failed</b></span></a><br />\n";
}
$URL = $orig;
}
exit(0);
Not working... any ideas?