Perlwannabe
Technical User
Hello,
I made a short cgi script in order to submit automatically new pages on my web site;what that script should do,is to "pick up" a random number of titles from a text file called key_list.txt and submit them to a specific form on a control panel(cgi)that "transforms" them in real html pages.
Also,it should be "cronned", in order to get constant daily submission.
Really what happens is that the script itself seems to work fine, the cron job output confirm the number and the name of the new submitted pages, but when I enter the control panel, no new page is added...
I already checked the script a million of times but I'm not able to understand where is the error.
Seems like if the script is not ableto enter the cpanel...
Could someone help me,please?
Here is the script I'm trying in localhost at the moment (already tested unsuccessfully on a real server):
Thanks in advance for any help
Sincerely
I made a short cgi script in order to submit automatically new pages on my web site;what that script should do,is to "pick up" a random number of titles from a text file called key_list.txt and submit them to a specific form on a control panel(cgi)that "transforms" them in real html pages.
Also,it should be "cronned", in order to get constant daily submission.
Really what happens is that the script itself seems to work fine, the cron job output confirm the number and the name of the new submitted pages, but when I enter the control panel, no new page is added...
I already checked the script a million of times but I'm not able to understand where is the error.
Seems like if the script is not ableto enter the cpanel...
Could someone help me,please?
Here is the script I'm trying in localhost at the moment (already tested unsuccessfully on a real server):
Code:
#!perl
# Configuration
# cpanel psw
$password = 'blabla';
# cpanel url
$admin_url_base = '[URL unfurl="true"]http://localhost/cgi-bin/sector/test/control.cgi';[/URL]
# cpanel data folder
$data_dir = 'data';
# minimum pages number
$minpages = 1;
# maximum pages number
$maxpages = 5;
# path to this script (for cron job)
$fullpath = '/indigoperl/apache/cgi-bin/sector/test/';
##### script #####
use CGI::Carp qw (fatalsToBrowser);
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$keywords = 'key_list.txt';
$klist = '';
$admin_url = $admin_url_base . '?createpages';
open (KEYS, "<$fullpath$keywords");
@kd = <KEYS>;
close (KEYS);
srand();
$range = $maxpages - $minpages;
$random_number = int(rand($range)) + $minpages;
for ($a=1;$a<=$random_number;$a++){
$klist .= shift(@kd);
}
chomp($klist);
@completed = split(/\n/,$klist);
open (KEYS, ">$fullpath$keywords");
print KEYS @kd;
close (KEYS);
$req = (POST $admin_url,
[
'pass' => $password,
'dataflag' => '1',
'pagenames' => $klist
]);
$response = $ua->request($req);
print "Content-type: text/html\n\n";
print "Number of pages created: $random_number<br>\n";
foreach(@completed){
print $_."<br>\n";
Thanks in advance for any help
Sincerely