The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-17-2009
GoldenEye4ever GoldenEye4ever is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 5
Help executing command loaded from file

I need to execute a command that is loaded from a file.

Basically, we have several scripts that need to be run at scheduled times.
We're going to store those times in the database and update a file with data.
In that file we'll have scriptName, inputParameters, runTimes, etc...
I chose to use tilda (~) as the delimiter as it can't be used by any of the input variables

I got it all working, with one exception.
If an inputParameter needs to be executed (current date `date +'%d%m'`)

Then I get this error:
./chk_master_script.sh[247]: `date +%m%d`: not found Launching script (with parameters): $HOME/daily/scripts/workit.sh
-->
Code:
./chk_master_script.sh[247]: `date +%m%d`:  not found
Launching script (with parameters): $HOME/daily/scripts/workit.sh
        
This is roughly how I load the data:
if [ -s ${masterDataFile} ]; then fileExists=true IFS="~" while read workerScript parameters timingStuff; do ... params=`${parameters}` echo "Launching script (with parameters): ${workerScript} ${params}" ... done -->
Code:
if [ -s ${masterDataFile} ]; then
  fileExists=true
  IFS="~"
  while read workerScript parameters timingStuff; do
    ...
    params=`${parameters}`
    echo "Launching script (with parameters): ${workerScript} ${params}"
    ...
  done
        
File Layout:
filename~parameters~schedulingStuffHere -->
Code:
filename~parameters~schedulingStuffHere
        
Sample File Contents:
workerScript.sh~`date '+%m%d'`~stuffGoesHere -->
Code:
workerScript.sh~`date '+%m%d'`~stuffGoesHere
        
Thanks