in reply to if elsif elsif prints all three.

Here's a crazy idea: put each little block of code in its own file. So, create a file with this content:

#!/bin/sh /usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect - +q >> $1 2>&1

and name it 'start-bgs' in some directory. Then do the same for all other other case blocks and name them similarly. Then your script just becomes:

#!/bin/sh ... # set $agent to the agent you want to start cmdpath=$cmd_dir/start-$agent if ! -x $cmdpath; then echo Error - start script $cmdpath not found exit 1 fi $cmdpath $LOG # pass any relevant parameters here

Then when you need to add/change/delete agents you are just replacing files instead of trying to edit a few lines in a file. This should make things a lot easier to manage, especially if you have several hundred files to update.

It's a crazy idea!

Replies are listed 'Best First'.
Re^2: if elsif elsif prints all three.
by wcj75019 (Acolyte) on Feb 28, 2008 at 17:36 UTC
    That makes sense. But, all the files are different. I can only change or add those lines to them. Thanks,