I have a cgi file that I would like to run as a cron job. What it does is update a table in a database
I have tried to set up the cron job through the control panel but it does not work. The hint says to set it up like this
Hint: to run CGI files, enter the command as follows (modify to fit your needs):
GET http://yourdomain.com/cgi-bin/path_to_file/file.cgi > /dev/null
Here is what I have tried
GET http://MyDomain/MyDirectory/MySubDirectory/inv.cgi > /dev/null
and
http://MyDomain/MyDirectory/MySubDirectory/inv.cgi
and
/usr/local/bin/perl /home/MyDomain/public_html/MyDirectory/MySubDirectory/inv.cgi
and
GET /usr/local/bin/perl /home/MyDomain/public_html/MyDirectory/MySubDirectory/inv.cgi > /dev/null
this is the inv.cgi file located in MySubDirectory
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use DBI;
@days = ("Sun","Mon","Tue","Wed","Thu","Fri","Sa t");
@months = ("Jan","Feb","Mar","Apr","May","Jun","Ju l","Aug","Sep","Oct","Nov","Dec");
print "Content-type: text/html\n\n";
$sc_mysql_server_name = "localhost";
$sc_mysql_database_name = "MyDomain_Mdb";
$sc_mysql_user_name = "Display";
$sc_mysql_password = "Purpose";
$sc_mysql_dsn = "DBI:mysql:$sc_mysql_database_name:$sc_m ysql_server_name";
$sc_mysql_prd_table = "product";
$inv_file = "./files/inv.file";
($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime(time);
print qq~
Start Update $hour:$min:$sec
~;
$dbh = DBI->connect("dbi:mysql:$sc_mysql_database_n ame:$sc_mysql_server_name","$sc_mysql_us er_name","$sc_mysql_password") || die("Couldn't connect to database!\n");
open (REC, "< $inv_file") || die "Cant open $inv_file";
while (<REC>)
{
@data = split(/\|/, $_);
$query = "UPDATE $sc_mysql_prd_table SET userone=\'$data[1]\' WHERE usertwo=\'$data[0]\'";
# print "$query\n";
$dbh->do($query);
}
close (REC);
$dbh->disconnect;
($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime(time);
print qq~
Inventory Updated $hour:$min:$sec
~;
Any Ideas where I have gone wrong


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks