#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI qw/:cgi-lib/;
use CGI::Carp qw(fatalsToBrowser);
%FORM=Vars();
#Instructions
##################
#Set this to the server path to the crons.txt
$pathtocrontxt="/var/www/vhosts/mydomain/cgi-bin/crons.txt";
# In the crons.txt put the first line as 0 and then put each cronjob on a seperate line below
# set the chmod permissions to crons.txt to 777 and cron.cgi to 755
#####################################
print "Running Crons...\n";
open(INF,"$pathtocrontxt") or print "couldnt open file";
@commands=;
close(INF);
foreach $line(@commands){
chomp($line);
if($line == 0){
print "not working\n";
@commands[0]="1\n";
open(OUTF,">$pathtocrontxt");
foreach $command(@commands){
print OUTF "$command";
}
close(OUTF);
}
elsif($line == 1){
print "working";
exit;
}
else {
print "Executing: $line\n";
$output=system("$line");
print "$output\n";
}
}
@commands[0]="0\n";
open(OUTF,">$pathtocrontxt");
foreach $command(@commands){
print OUTF "$command";
}
close(OUTF);
print "\n\nDone!\n";