Executing jobs as stored in database
Hi everyone,
I am coping with a problem for a few weeks already. After extensive searching I still can't find the solution. Here is my problem: I have a MySQL database with a table that has job commands, like: $SCRIPTDIR/path/to/script.sh "param1" "param2" I have a script that executes a query and retrieves the value from that column. I echo'd the value (stored in $JOBCOMMAND) and it is correct. So that part works. Now I try to execute the job as: `$JOBCOMMAND` --> fails $($JOBCOMMAND) --> fails `echo $JOBCOMMAND` --> fails `$($JOBCOMMAND)` --> fails The error: No such file or directory. The actual problem (as I see it) is that I have a $ in the job command, which does not get parsed. I am trying hard to avoid eval, but I am completely lost. Does anyone have any suggestions? Thank you for your time and effort. |
I am unsure where you are saying the $ is. Is it part of the command itself stored in $JOBCOMMAND, or the variable name is $JOBCOMMAND instead of JOBCOMMAND?
|
It is part of the command itself stored in $JOBCOMMAND
When doing: echo $JOBCOMMAND, the result is: $SCRIPTDIR/path/to/script.sh "param1" "param2" |
Like this?
Code:
lm ~ # SCRIPTDIR=/tmp |
That would work, except ... ;-)
At this moment I have 1 variable, $SCRIPTDIR. There will be more in the future and I don't want to update the script for each new variable. |
Can you post any of your script then?
|
I solved it for now:
Code:
#!/bin/bash 1. I will have to create a substitute value for each parameter. 2. I will have to update the CREATE_COMMAND function for each parameter. 3. I changed the variable names from $PART to {@PART} in the value, since I could not find a way to parse $PART. There was nothing I could think of that was clean and elegant. Thank you for your time and effort! |
All times are GMT -5. The time now is 12:24 PM. |