Sponsored Content
Top Forums Shell Programming and Scripting Shell script menu for end user - difficult challenge Post 302565817 by Chubler_XL on Tuesday 18th of October 2011 09:39:32 PM
Old 10-18-2011
How about this:

Code:
#!/bin/bash
while true
do
   printf "Please insert number of steps? "
   read steps
   [ "$steps" -gt 0 ] 2> /dev/null && break
   printf "Invalid number - please try again\n\n"
done
step=1
while [ $step -le $steps ]
do
  printf "Insert Step $step? "
  read step_cmd[step]
  if [ -f "${HOME_DIR}/bin/${step_cmd[step]}" ]
  then
      let step=step+1
      while true
      do
           printf "Please check return code for ${step_cmd[step]}? "
           read step_ret[step]
           [ "${step_ret[step]}" -ge 0 ] 2> /dev/null && break
           printf "Invalid number - please try again\n\n"
      done
      printf "\n"
  else
      printf "Illegal step script not found - please try again\n\n"
  fi
done
 
printf "Check before running the scripts:\n"
i=1
while [ $i -le ${#step_cmd[*]} ]
do
   printf "  %d. %s -- return code %d\n" $i ${step_cmd[i]} ${step_ret[i]}
   let i=i+1
done
printf "For continue insert yes: "
read continue
if [ "$continue" = "yes" ]
then
    i=1
    while [ $i -le ${#step_cmd[*]} ]
    do
       sudo -u root ${HOME_DIR}/bin/${step_cmd[i]}
       if [ $? -ne ${step_ret[i]} ]
       then
           echo "Script #$i failed - exiting"
           exit 2
       fi
       let i=i+1
    done
else
    echo "Not confirmed - aborting"
    exit 1
fi


Last edited by Chubler_XL; 10-18-2011 at 10:44 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

2. Shell Programming and Scripting

need shell script for this challenge problem

two tabulate files (A, B), each contents thousands and thousands lines with ids. first find out contents with common ids in both A, B and print out into a file; second find out contents with ids which only exist in file A and print out into a file. (4 Replies)
Discussion started by: ssshen
4 Replies

3. Shell Programming and Scripting

Shell script menu

hi guys, how would you do the following? I have a menu with 5 options in my shell script: 1. Run function 1 against files 2. Run function 2 against files 3. Run function 3 against files 4. Run function 4 against files 5. Run function 5 against files I'd like to be able to run multiple... (10 Replies)
Discussion started by: rich@ardz
10 Replies

4. Shell Programming and Scripting

Menu using shell script

Hi, I need to have a shell script for the below need. 1. Menu with one heading and 4 options. 2. the heading and 4 options are taken from a file. File entry ====== Heading1|option1|option2|option3|option4| Heading2|option1|option2|option3|option4| 3. the user entries must be captured in... (9 Replies)
Discussion started by: umastinu
9 Replies

5. Shell Programming and Scripting

Shell script menu problem

I have tried searching the forum but i haven't found a solution for this. I have a shell script that presents the users with menus. The menus branch out to sub menus. It is all hunky dory as long as i traverse forward. But if i am in a sub menu and return to the previous menu and choose any... (11 Replies)
Discussion started by: goddevil
11 Replies

6. Shell Programming and Scripting

Shell script menu for end user - difficult challenge 2

Hello, I need to make shell script menu for my end users. There is like 100 scripts in system, and they need to run that scripts true one main script with user friendly menu. Example, when user will run main menu script, it will get something like this on his screen:... (1 Reply)
Discussion started by: waso
1 Replies

7. Shell Programming and Scripting

A selection menu in a shell script

I'm writing a shell script and have a problem with selection when I issue the command, is there a way to automatically choose a selection number one after a selection menue appear Command 1-choice 2- choice 3-choice Thanks Sara (3 Replies)
Discussion started by: Sara_84
3 Replies

8. Shell Programming and Scripting

Menu shell script help

Hi All, I have written a shell script that show menu driven option. My requirement is that in the menu driven option i want to select multiple choice. i.e if i want to select 1 or 1,2 or 1,2,3 or 2,3 etc .... Can some one help me in that My script. while true; do echo " " ... (8 Replies)
Discussion started by: Nawrajesh
8 Replies

9. Shell Programming and Scripting

Automate the menu options using shell script

I have a menu option which will look as follows Select a menu option 1.change password 2.login as root user 3.show system version 4.quit Select> 1 please enter the new password: unix reenter the new password: unix press any key to enter (then displays again the menu options to enter the... (4 Replies)
Discussion started by: shivakumar6g
4 Replies
DH_INSTALLMENU(1)						     Debhelper							 DH_INSTALLMENU(1)

NAME
dh_installmenu - install Debian menu files into package build directories SYNOPSIS
dh_installmenu [debhelperoptions] [-n] DESCRIPTION
dh_installmenu is a debhelper program that is responsible for installing files used by the Debian menu package into package build directories. It also automatically generates the postinst and postrm commands needed to interface with the Debian menu package. These commands are inserted into the maintainer scripts by dh_installdeb(1). FILES
debian/package.menu Debian menu files, installed into usr/share/menu/package in the package build directory. See menufile(5) for its format. debian/package.menu-method Debian menu method files, installed into etc/menu-methods/package in the package build directory. OPTIONS
-n, --no-scripts Do not modify postinst/postrm scripts. SEE ALSO
debhelper(7) update-menus(1) menufile(5) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_INSTALLMENU(1)
All times are GMT -4. The time now is 01:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy