in reply to Am I missing something major here (system/exec)?

kjg:

Since others are helping you on the Web/CGI/HTML front, I'm going to suggest a different tack: You might want to have a scheduled job that runs your batch jobs for you, and make your web interface simply trigger them. The method I use is having my scheduled job simply look for the presence of files in a particular directory. When it sees one, it executes the appropriate script with the trigger file passed in as the argument. (This way your Web app can send in any configuration values to the script--such as the EMail address to send the report to)

This way, you can avoid some of the potential security problems mentioned by ptum and the forking problem mentioned by ww. My favorite reasons for this method, however, are:

  • You don't have to tie up an http thread while your script runs.
  • Other programs can easily trigger the same jobs.
  • Easy to test!
  • A single point of control for all batch jobs. Turn off your batch job, and nothing gets processed until you restart it! (Very nice if you're trying to do some maintenance, and don't want database records changing or getting locked under you.)

    Your scheduled job can be as simple as:

    REM DOIT.BAT REM REM Note: the .pl scripts are expected to delete their command file D: cd \WORK\QUEUE :LOOP sleep 60 if exists PAUSE_JOB goto LOOP for %%J in (NME\*) do NME_Rpt.pl %%J for %%J in (PURGE\*) do Purge_Old_Files.pl %%J goto LOOP
    Note: I'm typing in the batch file from memory, so consider it untested (and likely incorrect in some details)!

    --roboticus