Sponsored Content
Full Discussion: Quit Function Issues
Top Forums Shell Programming and Scripting Quit Function Issues Post 302310549 by warlock129 on Saturday 25th of April 2009 02:50:46 PM
Old 04-25-2009
Quit Function Issues

Hi everyone,

I am writing a small menu driven program and have come across a problem i am having trouble solving. I am using Windows XP and i am developing this in the Unix Bash shell. I am trying to make it possible to exit the program from each of the five main interfaces. The code is as shown below:

Code:
#!/bin/bash
#Filename: Assigntest Author: Luke Francis
quit=n
while [ "$quit" = "n" ]
do
clear
echo "OPERATOR ADMINISTRATIVE TOOL"
echo "1. User Information"
echo "2. Network Connectivity"
echo "3. Processes"
echo "4. System Information"
echo "5. Hardware Utilization"
echo "Q. Quit"
echo
echo "Which option do you require?"

read menunumber
case $menunumber in
1)clear
echo "USER INFORMATION"
 echo "1. Registered Users"
 echo "2. Disk Usage"
 echo "3. Last Logins"
 echo "4. Users Currently Logged In"
 echo "5. Total number of users"
 echo "Q. Quit"

echo "Which option do you require?"

read menunumber2
case $menunumber2 in

1)clear
echo "The users registered on the system are:"
echo
awk -F: '{print $1}' /etc/passwd
echo
echo "Hit the Enter Key to continue"
read junk;;

2)clear
echo "Disk Usage is as follows:"
echo
du
echo
echo "Hit Enter Key to continue"
read junk;;

3)clear
echo "Information on last noted login can be found next to each username."
echo
last
echo
echo "Hit Enter Key to continue"
read junk;;

4)clear
echo "Users currently logged in are:"
echo
 w
echo
echo "Hit Enter Key to continue"
read junk;;

5)clear
echo "The total number of users are:"
echo
 who -q
echo
echo "Hit Enter Key to continue"
read junk;;

Q|q)clear
echo "Are you sure you want to quit? Y/N"
read choice1
case $choice1 in
N|n)clear
echo "Hit Enter Key to continue"
read junk;;

Y|y)quit=y;;
*)clear
sleep 1
esac
esac
esac
done
clear
echo "Thank you for using the Operator Administrative Tool"


My quit command at the bottom (code after Q|q) ) works fine but i am trying to apply it to my main menu (after "OPERATOR ADMINISTRATIVE TOOL") where and how within my code shall i go about doing this?

I'd be really grateful for some help. thanks
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to quit from glance

hi, if i am in glance, how do i exit? thanks (2 Replies)
Discussion started by: yls177
2 Replies

2. Shell Programming and Scripting

quit any time

how can i read input to quit any time, for instance "type q to quit" I have a script like this echo "The first choice" read firstChoice echo "The second choice" read secondChoice Looking for a code to quit any time by pressing q to quit any help would be appreciated thanks (5 Replies)
Discussion started by: Qwond
5 Replies

3. Shell Programming and Scripting

How to quit from a script?

hi all, I am facing problem in shell scripting while using exit command, when ever i run a file using . ./<filename>, when i run the sae script as sh <filename> the script does not close the windows. since my script has function calls i have to use . ./ <filename>. Could any one tell me... (8 Replies)
Discussion started by: caro
8 Replies

4. Programming

performance issues of calling a function in if condition

Hi, I have written a program in C and have to test the return value of the functions. So the normal way of doin this wud b int rc rc=myfunction(input); if(rc=TRUE){ } else{ } But instead of doing this I have called the function in the if() condition. Does this have any... (2 Replies)
Discussion started by: sidmania
2 Replies

5. Shell Programming and Scripting

if no file then quit

I have a script that run several subscripts. I need to find out how to do two things. First I would like to check for a file and if that file is not there I want to quit the entire script without running the rest of the script which contain subscripts. If the file is there, I want it to continue... (1 Reply)
Discussion started by: libertyforall
1 Replies

6. UNIX for Advanced & Expert Users

how to quit or exit from WMToggle

I want directly to move from WMToggle to bash, which command to type? Now I need to type 3 times, :q! etc. any help? its very annoying to time something 3 times continuously :( (1 Reply)
Discussion started by: c_lady
1 Replies

7. Shell Programming and Scripting

Need to quit out of for loop.

Hi, Here is my code to send read.txt to three servers. col="prd167.mybank.com prd168.mybank.com bsprd169.mybank.com" set -A look $col for IndixList in ${look}; do scp /tmp/read.txt admin@$IndixList:/tmp done This works and all the 3 servers gets the read.txt file. However,... (8 Replies)
Discussion started by: mohtashims
8 Replies

8. Shell Programming and Scripting

Function Issues

I am converting English letters/words/punctuation in leet speak. My current script works just fine, but when I call the functions it seem to be bypassing my second function altogether. I am new to shell scripting so excuse me if its an easy fix. Also, when using SED for whole word phrases like... (4 Replies)
Discussion started by: bri09
4 Replies

9. OS X (Apple)

Are you sure you want to quit Safari?

Hmmm. I cannot figure out where to disable this warning message in Safari. Google says to disable something in Safari Tabs preferences but my Macs do not have that option in Mojave. Anyone know how to disable the following so when I quit Safari it simply quits without the "freeze the... (12 Replies)
Discussion started by: Neo
12 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 02:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy