mmcw
asked on
400 URL must be absolute
I am using the following code:
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Code
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
#!/usr/bin/perl
my $debug_fake_cron = 1;
use LWP;
my $row = "http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi";
print "Content-type: text/html\r\n\r\n" if ($debug_fake_cron);
print "Start execute command: $executable ($row)<br />" if ($debug_fake_cron);
my $browser = LWP::UserAgent->new();
$browser->agent("SmartCron ");
$browser->timeout(5);
my $response = $browser->get('$row');
if ($response->is_success) {
print "Success: " .$response->content . "<br />" if ($debug_fake_cron);
}
else {
print "Error: " .$response->status_line . "<br />" if ($debug_fake_cron);
}
print "Execute command: $row<br />" if ($debug_fake_cron);
$browser->request(HTTP::Request->new(GET => $row)) or ($error = 1);
exit(0);
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
It will return the following:
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Start execute command: (http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi)
Error: 400 URL must be absolute
Execute command: http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
However I get the message: 400 URL must be absolute
What does it mean and what am I doing wrong to make this work?
--------------------------
Code
--------------------------
#!/usr/bin/perl
my $debug_fake_cron = 1;
use LWP;
my $row = "http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi";
print "Content-type: text/html\r\n\r\n" if ($debug_fake_cron);
print "Start execute command: $executable ($row)<br />" if ($debug_fake_cron);
my $browser = LWP::UserAgent->new();
$browser->agent("SmartCron
$browser->timeout(5);
my $response = $browser->get('$row');
if ($response->is_success) {
print "Success: " .$response->content . "<br />" if ($debug_fake_cron);
}
else {
print "Error: " .$response->status_line . "<br />" if ($debug_fake_cron);
}
print "Execute command: $row<br />" if ($debug_fake_cron);
$browser->request(HTTP::Request->new(GET
exit(0);
--------------------------
It will return the following:
--------------------------
Start execute command: (http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi)
Error: 400 URL must be absolute
Execute command: http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi
--------------------------
However I get the message: 400 URL must be absolute
What does it mean and what am I doing wrong to make this work?
ASKER
Untill for short the following code was working!
Now it is stopped?
#!/usr/bin/perl
my $debug_fake_cron = 1;
use LWP;
my $row = "http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi?action=update_correction&use_cron=1";
my $browser = LWP::UserAgent->new();
$browser->agent("SmartCron ");
$browser->timeout(5);
$browser->request(HTTP::Request->new(GET => $row));
print "Content-type: text/html\r\n\r\n" if ($debug_fake_cron);
print "Execute command: $row<br />" if ($debug_fake_cron);
exit(0);
What is wrong and how to fix it?
Now it is stopped?
#!/usr/bin/perl
my $debug_fake_cron = 1;
use LWP;
my $row = "http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi?action=update_correction&use_cron=1";
my $browser = LWP::UserAgent->new();
$browser->agent("SmartCron
$browser->timeout(5);
$browser->request(HTTP::Request->new(GET
print "Content-type: text/html\r\n\r\n" if ($debug_fake_cron);
print "Execute command: $row<br />" if ($debug_fake_cron);
exit(0);
What is wrong and how to fix it?
I have no idea what you are expecting the code to do, so I don't know what it has stopped doing :)
You don't seem to be checking the response at all. What unexpected behaviour are you seeing?
Dave...
You don't seem to be checking the response at all. What unexpected behaviour are you seeing?
Dave...
ASKER
How to check the response?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It looks like it will not except the "?action=update_correction &use_cron= 1" part.
Do I have to make some changes therefor?
Do I have to make some changes therefor?
ASKER
To explain what I want to do with the script (lets call it script.pl) is that I want to start the URL given ("http://www.mmc-shop.nl/cgi-bin/Shop/shop_art.cgi?action=update_correction&use_cron=1") at the background! But there doesn't have to be a redirection to that URL and the starting script (script.pl) has to be continuet! That was and is my problem from the starting on! The 400 error line was the first problem I can with when I tried to use teh responce option to see what I am doing wrong?
Or am I doing it completely wrong and have to do it another way??
Or am I doing it completely wrong and have to do it another way??
ASKER
When I try a line as:
print "Location: $row\n\n";
It will start the script given at $row but will redirect to that script and will not return to the main script! Thats my problem. Thats why I made it a difficult (250 points) question!
print "Location: $row\n\n";
It will start the script given at $row but will redirect to that script and will not return to the main script! Thats my problem. Thats why I made it a difficult (250 points) question!
ASKER
As a cron command executed on a sertain time and date!
ASKER
Thank you for your reply!
I did found the solution myself.
The code I asked you to look for wasn't the problem but it was in the script to be executed!
I did found the solution myself.
The code I asked you to look for wasn't the problem but it was in the script to be executed!
This line isn't doing what you think it is. The single quotes prevent $row from being expanded, so instead of requesting the url which is in $row, you are requesting the literal string '$row' - which (obviously) isn't a well-formed URL.
If you want variables to be expanded in strings then you need to use double quotes, not single quotes.
my $response = $browser->get("$row");
But in this case, there's absolutely no reason at all to use quotes.
my $response = $browser->get($row);
Dave...