Click to See Complete Forum and Search --> : A script to run scripts


jns
02-03-2003, 02:28 PM
I'm afraid my question will demonstrate just how little I know about Perl scripting, but here goes.

I have a variety of scripts that are automatically run through a cron job. In a few instances where I have had a problem with my connection or server, the job wouldn't run as scheduled. When that happens, it causes problems with the appearance of my web site.

Now, when I want to refresh the site by running these scripts manually, I have to run each script individually through shell commands.

What I'd like to have is a password-protected page where I could go to remotely, click on a button, and have all of the commands run from that one command. In other words, I'd like a one-stop location to run all of the script commands that appear in my cron so that I don't have to wait until the next time they are run by the cron.

Any ideas?

I'm thinking this wouldn't be too difficult, but I don't know where to start.

Thanks to all who may have advice.

jns

Paco Zarabozo
02-07-2003, 04:38 PM
You can pass your password directly on the address:
http://yourserver.com/thisScript.cgi?yourPassword
This would do the job:
______________________
#!perl
$| = 1;
print "Content-type:text/html\n\n";

if ($ENV{QUERY_STRING} ne "yourpassword") {
print "Wrong password.";
exit;
}

#This is an array containing every command
#you want to pass to the system. Write them
#exactly like you would write them on a command line.
#I'm using four very different examples:

@commands = ('script_A.pl', 'del *.log', 'perl script_B.pl', 'myProgram.exe');

#Now, here's where they will be executed:

foreach $i (@commands) {
print "EXECUTING $i:<br><br>\n";
@answer = `$i`;
foreach $line (@answer) {
#This just prints the answer:
print "executed> $line<br>";
}
print "$i done!<hr>\n";
}

print "Finished. All commands executed.";
exit;

jns
02-07-2003, 05:05 PM
I didn't expect a custom script, but thanks so much. It works beautifully!

jns

Paco Zarabozo
02-07-2003, 05:32 PM
Nice. :-)
I didn't test it. I'm glad it worked.

Paco.

jns
02-24-2003, 03:42 PM
Sorry, but it doesn't seem to work. It operates as if it's working. Reports with the proper messages as if it's working. But the scripts don't seem to be running.

Any suggestions on how to trace the hang up?

-jns

celebguy_dv
03-04-2003, 01:58 AM
http://banners.dollarmachine.com/pic/2014000/hal001.gif (http://www.kinkyceleb.com/1261795520)