The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-09-2008
Registered User
 

Join Date: Jun 2008
Posts: 1
stubscript

In the past, I have done the following using a large set of case statements, but I've been asked to simplify:

I need to write a bash script that will detect for the existence of other bash scripts which live in a sub-folder and if the script exists in the sub directory, run it. The names for the scripts will be passed to the stubscript from the command line (actually a zenoss monitoring server) they will not be hard coded into the stub script itself. I know this sounds a bit odd, but by using a huge list of case statements, it's not as scalable.

The idea is that you can simply add other bash script inside this subfolder and the stubscript will always stay the same. You then change the command line sent from the monitoring server to the stubscript on the remote server when a fault is detected. The name of the script to be run would come across with the command.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-10-2008
Registered User
 

Join Date: Jun 2008
Location: Scotland
Posts: 79
If the script to run is the first command-line argument, then you probably want something like
Code:
[ -f $subdir/$1 ] && bash $subdir/$1
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0