Sponsored Content
Top Forums Shell Programming and Scripting script that reads all the scripts in the directory and run them within that script Post 302324165 by rakeshawasthi on Wednesday 10th of June 2009 06:23:33 AM
Old 06-10-2009
I have modified this script to tackle 3 issue which I could see.
1) same what you mentioned, calling files dynamically
2) handling wrong input
3) if the script is put in a file, lets say prog.sh, this will be listed in the menu and if an option is chosen to select it, the program will go recursive.

I have modified the script a bit, instead of writing a fresh program...

Code:
print_menu()
{
  n=1
  bar======================================
  printf "%s\n" "$bar" " Please Select a Script"  "$bar"

  for item
  do
     if [[ $item != $prog ]]
     then
      printf "%3d: %s\n" "$n" "$item"
      n=$(( $n + 1 ))
     fi
  done

  echo $prog
  printf "%3d: %s\n" "$n" "Quit"

  printf "%s\n Select 1-%d: " "$bar" "$n"
}

prog=$0
while :
do
  print_menu *.sh
  read x
  case $x in
    [1-$(( $n - 1 ))]) sh `ls -1 *.sh | grep -v $prog | head -n $x | tail -1` ;;
       $n) exit  ;;
        *) echo "Wrong Input\n"
  esac
done

I think it should work for the time being...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run scripts within a script..

Hi all... I have several scripts of varying types (shell script, expect script, awk script) that I would like to run within 1 script.. They also take a command line argument (which it is getting successfully). The problem is, the parent script is exiting after the first script it calls is... (2 Replies)
Discussion started by: earnstaf
2 Replies

2. Shell Programming and Scripting

Check if script run by a user directly or via other scripts

Hi, i have a script 'a.sh' that should be called only by certain scripts like b.sh, c.sh Inside a.sh, how can i determine 1) if this script was run directly from command prompt (or scheduler) 2) if called via other scripts? Is there an easy way to get parent process name (not just pid),... (2 Replies)
Discussion started by: ysrinu
2 Replies

3. Shell Programming and Scripting

1 script or multiple scripts?? - check files, run jobs

Question for anyone that might be able to help: My objective is to eheck if a file (a source file) exists in a directory. If it does then, I'd like to call an application (Informatica ETL file...not necessary to know) to run a program which extracts data and loads it into multiple targets. ... (6 Replies)
Discussion started by: jnanasakti
6 Replies

4. UNIX for Dummies Questions & Answers

Sh script to run multiple php scripts

I wrote a .sh script to run 5 php scripts. The problem is that it's running 1 then 2 then 3 in that order .... I want it to execute all 5 at ONCE.... nohup php /home/script1/script1.php && nohup php /home/script2/script2.php && nohup php /home/script3/script3.php && nohup php... (1 Reply)
Discussion started by: holyearth
1 Replies

5. Shell Programming and Scripting

Shell script to run all the python scripts from particular directory

I have N number of python scripts which i am receiving from REST web server and i am saving them in /home/mandar/ . Now i want to write a script to run all the python scripts from this directory and monitor them every minute...if any process is dead or hung it should be restarted by this script. ... (0 Replies)
Discussion started by: Mandar Nandale
0 Replies

6. Shell Programming and Scripting

Using a script to define variables and run multiple other scripts in succession.

I'm pretty new to scripting in Korn shell so please forgive me... What I'm trying to do is to create a script that calls multiple other ksh scripts and defines variables for text files. I need it to define my user defined variables (file paths, date & time stamps, etc that are currently in... (1 Reply)
Discussion started by: bluejwxn8
1 Replies

7. UNIX for Dummies Questions & Answers

Trying to make a script to run 3 other scripts in a screen.

Hello, my name is Spurkle. I'm new to linux stuff. Currently I am trying to make a script which will run three other scripts in screen. This is the code: sudo screen -S hubServ /var/servers/hub/hub.sh sudo screen -S facServh /var/servers/factions/factions.sh sudo screen -S bunServ... (5 Replies)
Discussion started by: Spurkle
5 Replies

8. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

9. Shell Programming and Scripting

Run 2 shell scripts simultaneously from one script

i Run 2 scripts on all of around 50 nodes every day. 1.Mod_1.sh 2.Mod_2.sh eg.. i run file with specific node no like Mod_1.sh NODE_(node number) Mod_2.sh NODE_(node number) I want to run both file by using single script with unique node number. Eg.. Mod_new.sh NODE_(node... (11 Replies)
Discussion started by: Ganesh Mankar
11 Replies

10. UNIX for Beginners Questions & Answers

A single script to run multiple scripts

Hi , Can someone help! I need a shell script to run multiple scripts by using single shell script, incase any one of the scripts fails, it should get exit and after trouble shooting if we re-execute it, it should start from the failed script. I have a written a scripting till the... (1 Reply)
Discussion started by: anniesurolyn
1 Replies
RATMENU(1)						      General Commands Manual							RATMENU(1)

NAME
ratmenu - create a menu to run commands SYNOPSIS
ratmenu [ -display displayname ] [ -font fname ] [ -fg foreground-color ] [ -bg background-color ] [ -io item-offset ] [ -label name ] [ -shell prog ] [ -align {left|center|right} ] [ -style {snazzy|dreary} ] [ -persist ] [ -version ] [ menuitem command ] ... DESCRIPTION
ratmenu is a simple program that accepts a list of menu item and command pairs on the command line. It creates a window that consists of nothing but a menu. When a particular item is selected, the corresponding command is executed. ratmenu does not recognize any usage of the rodent. It is entirely keystroke operated. Menu items must be followed by a command. The syntax is based on that of the dialog program. ratmenu accepts the following command line options. -display displayname Use the X display displayname, instead of the default display. -font fname (X Resource: font) Use the font fname, instead of the default font. -label name Change both the window and icon labels of the window to name. The default label is the last component of the path used to run ratmenu, typically, ratmenu. -fg foreground-color (X Resource: fgcolor) Set the foreground color to foreground-color. By default, the foreground color is black. -bg background-color (X Resource: bgcolor) Set the background color to background-color. By default, the background color is white. -io item-offset Set the first selected item to item-offset. By default, the first item is the top-most one, or item-offset 1. The next item down would be at item-offset 2. -style {snazzy|dreary} (X Resource: style) The default style is snazzy, where the highlight bar, which shows the currently selected item, remains stationary while all the menu items are rotated up or down when the cursor keys are moved. In dreary mode, the highlight bar moves up and down the menu as it does on all conventional keyboard controlled menus. -align {left|center|right} (X Resource: align) Align the text of the menu entries to the left, right, or center. Defaults to left. This is different from 9menu, which defaults to center. -shell prog Use prog as the shell to run commands, instead of /bin/sh. A popular alternative shell is rc(1). If the shell cannot be executed, ratmenu will silently fall back to using /bin/sh. -back prevmenu prevmenu is a command or shell script to run when the back key is pressed, usually a script that has ratmenu showing the pre- vious menu. Used to create nested menus, it gives the user a way to back out and return to the previous menu. Note that you can use this option for other things too. The command specified by the -back option is executed when the user hits one of the "back" keys. -persist (X Resource: persist) Ordinarily, ratmenu exits if a new window pops up on top of it, or if you switch to another window. This option tells ratmenu to hang around, like a regular window. -version This option prints the version of ratmenu on the standard output, and then exits with an exit value of zero. KEYSTROKES
The Up keystrokes move the selection to the next item up. The Down keystrokes move the selection to the next item down. When the selec- tion reaches the top or bottom, it scrolls around to the other side on pressing of the appropriate keystroke. The Select keystrokes execute the command corresponding to the currently selected menu item, and exit ratmenu. The Exit keystrokes quit ratmenu without doing anything. Up 'k', Up_arrow, BackSpace, '-', C-p Down 'j', Down_arrow, Space, Tab, '+', C-n, C-i Select 'l', Right_arrow, Return, C-f, C-m, C-j Back 'h', Left_arrow, C-b Exit 'q', Escape, C-g CONFIGURATION USING X RESOURCES
You can configure some items using xrdb to load appropriate X resources. There is an example configuration in the file /usr/share/doc/rat- menu/Xresources.ratmenu which shows all possible configuration items. Give it a look; it is fairly easy to figure out. EXAMPLES
ratmenu -label "Remotes xterm" acme "rsh acme xterm" herman "rsh herman 9term" & ratmenu -label 'X progs' ghostview ghostview xdvi xdvi xeyes xeyes xneko xneko & ratmenu -back ~/bin/mypreviousmenu "X Eyes" xeyes & SEE ALSO
ratpoison(1), ratpoisonrc(5), dialog(1) xrdb(1) Ratpoison Desktop Users Manual. AUTHORS
The initial idea for this program was by Arnold Robbins, after having worked with John Mackin's GWM Blit emulation. Matty Farrow wrote a version using libXg, from which some ideas were borrowed. This code was written by David Hogan and Arnold Robbins. Rich Salz motivated the -shell option. Jonathan Walther modified this code to play nicely with the ratpoison window manager by removing handling of mouse events and iconification. Zrajm C Akfohg made many improvements in his ratmen fork, including X resource handling, some of which were folded back in. Ratpoison Desktop For X Oct 10 2001 RATMENU(1)
All times are GMT -4. The time now is 06:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy