www.webdeveloper.com
Results 1 to 6 of 6

Thread: A script to run scripts

  1. #1
    Join Date
    Feb 2003
    Posts
    6

    A script to run scripts

    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

  2. #2
    Join Date
    Nov 2002
    Location
    Mexico City
    Posts
    52
    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;

  3. #3
    Join Date
    Feb 2003
    Posts
    6

    Thanks!!!

    I didn't expect a custom script, but thanks so much. It works beautifully!

    jns

  4. #4
    Join Date
    Nov 2002
    Location
    Mexico City
    Posts
    52
    Nice. :-)
    I didn't test it. I'm glad it worked.

    Paco.

  5. #5
    Join Date
    Feb 2003
    Posts
    6

    I spoke too soon

    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

  6. #6
    celebguy_dv Guest

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles