Sponsored Content
Full Discussion: Bash menu script
Top Forums Shell Programming and Scripting Bash menu script Post 302375797 by AngelFlesh on Sunday 29th of November 2009 03:06:19 PM
Old 11-29-2009
Question Bash menu script

I have a main menu

Code:
quit=n 
while [  "$quit"   =   "n"  ] 
do 
clear 
echo 
echo "1. General system information" 
echo "2. Hardware utilisation information" 
echo "3. File management"
echo "4. User information"
echo "5. Information on network connectivity"
echo "6. Information on processes" 
echo "Q.Quit" 
echo 
echo "Enter choice" 
read choice 
case $choice in 
1)./gensysinfo
  read junk;;
2)./hardutilinfo
  read junk;;
3)./fileman 
  read junk;;
4)./userinfo
  read junk;;
5)./netinfo
  read junk;;
6)./procinfo 
  read junk;;
Q|q) quit=y;; 
*) echo "Try Again" 
sleep 1 
esac 
done 
echo "Thankyou, Come again"

This is a sub menu

Code:
echo
echo "1. Amount of RAM and the percentage used"
echo "2. Amount of swap space and the percentage used"
echo "3. Size of the CPU run queue and the extent to which the CPU is utilised"
echo "4. Main Menu"
echo
echo "Enter choice" 
read choice 
case $choice in 
1)free|awk '/Mem/{print "Total amount of RAM(Kbytes):" $2 "\nAmount of used RAM(%): " (($4 / $2) * 100)}'
echo
echo "Hit the Enter key to continue"
read junk;;
2)free|awk '/Swap/{print "Total amount of Swap Space(Kbytes):" $2 "\nAmount of used Swap Sapce(%): "(($4 / $2) * 100)}'
echo
echo "Hit the Enter key to  continue"
read junk;;
3)vmstat| tail -1 | awk '{print "Size of CPU run queue: " $1}'
top -bn1 | awk '/Cpu/{print "Amount of CPU utilised by us(userspace)(%): " $2 "\nAmount of CPU utilised by sy(system calls)(%): " $3 "\nAmount of CPU utilised by ni(reniced processes)(%): " $4 "\nAmount of CPU utilised by id(idle)(%): " $5 "\nAmount of CPU utilised by wa(waiting for i/o)(%): " $6 "\nAmount of CPU utilised by hi(hardware interrupts)(%): " $7 "\nAmount of CPU utilised by si(software interrupts)(%): " $8 }'
echo
echo "Hit the Enter key to continue"
read junk;;
4)./script
read junk;;
esac

What do i need to add to stay on the menu when "y" and go go to main menu when "n"

what I have atm just completes one option then quits menu.
I've been at this all day and my i can't see the solution..

I think it will be something like the first menu but i'm not sure how to go back to main when "n" is inputted.

Jade.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute interactive bash menu script in browser with PHP

I have an interactive menu script written in bash and I would like use PHP to open the interactive bash menu in a browser. Is this possible? Using the sytem() function in php runs the script but it's all garbled. Seems like maybe a terminal window needs to be opened in php first? ... (1 Reply)
Discussion started by: nck
1 Replies

2. Shell Programming and Scripting

Help regarding a bash menu script

Greetings all, I'm having some trouble writing a menu drive bash script, actually coding the menu part was not difficult however its a problem with a menu option I'm having trouble with. My menu has 5 options, when the user selects the second option, they are then prompted to enter a number from... (5 Replies)
Discussion started by: Vitrophyre
5 Replies

3. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

4. Shell Programming and Scripting

get chosen value from bash menu

Hi again :) This is just a sample whiptail menu. Works great, but have been trying to get the chosen value into a variable but failing pretty bad...its ther but unsure how to echo it out when needed #! /bin/bash #This is the menu whiptail --title "Menu example" --menu "Choose an... (9 Replies)
Discussion started by: olearydc
9 Replies

5. UNIX for Dummies Questions & Answers

Simple bash script menu

Dear Sir, May I know how do I go about adding the following feature into the script below: When user enter values other than 1,2,3,4, a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed b) The screen is cleared again and the menu is displayed. #!/bin/bash clear var=1... (2 Replies)
Discussion started by: fusetrips
2 Replies

6. Shell Programming and Scripting

Bash Script - Whiptail Menu Help!

Hello, Been trying to build a menu with whiptail lately. However, my code doesn't seems to be working even though when i compared to other similar code they looks the same. #!/bin/bash clear whiptail --msgbox "Entering networking sub-menu" 20 78 whiptail --title Networking --menu... (8 Replies)
Discussion started by: malfolozy
8 Replies

7. Open Source

Bash menu not running

The perl command is not executing? I am trying to run the .pl in my cygwin home directory (C:\cygwin\home\cmccabe) using ${id}.txt.hg19_multianno.txt (located in the annovar directory) as the input file to be formatted and $FILENAME is the output file to be saved. The .pl is attached as... (8 Replies)
Discussion started by: cmccabe
8 Replies

8. Shell Programming and Scripting

Menu Driven Bash Shell Script with Default Option

Hi All, I have written a menu driven bash shell script. Current Output is as below: ------------------------------------- Main Menu ------------------------------------- Option 1 Option 2 Option 3 Option 4 Exit ===================================== Enter your... (3 Replies)
Discussion started by: kiran_j
3 Replies

9. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

10. Shell Programming and Scripting

Bash Menu using zenity

Hi, I'm new to bash, and have an example menu script using Zenity. It works fine if the user enters A B or C, but if the user enters nothing, I can only figure out how to exit the script. How do I get the menu to reappear if no input is selected? The script is: title="Select example"... (2 Replies)
Discussion started by: allen11
2 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 06:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy