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
uncat(1)						      General Commands Manual							  uncat(1)

NAME
uncat - continuously reads stdin, splits up the data either by timeout or number of bytes read to process it SYNOPSIS
uncat [-vo] [-t seconds] [-s size] prog DESCRIPTION
uncat continuously reads stdin and repeatedly processes the data either after seconds timeout or maximal number of bytes size read. To process the data, uncat starts prog and feeds the data into prog's standard input. prog's standard output is redirected to standard error. uncat never writes to standard output. prog consist of one or more arguments. If prog exits non-zero, uncat prints an error message, discards the data and continues to read stdin. Note that uncat is not crash proof. uncat is used to run the socklog-notify service. OPTIONS
-v verbose. Print verbose messages to stderr. -o once. Exit on end of input. Normally uncat continues waiting for data on standard input, even on end of file. -t seconds timeout. Set the timeout to seconds seconds. Default is 300. -s size Set the maximal number of bytes to size. Default is 1024. SIGNALS
If uncat receives a TERM signal, it starts to process the data in memory and exits as soon as possible. uncat also does this on end of input if the -o option was given. EXIT CODES
uncat returns 0 after receiving a TERM signal. uncat returns 111 on error. SEE ALSO
socklog(8), socklog-conf(8), sv(8), runsv(8), svlogd(8), tryto(1) http://smarden.org/socklog/ http://smarden.org/runit/ AUTHOR
Gerrit Pape <pape@smarden.org> uncat(1)
All times are GMT -4. The time now is 01:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy