The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Pro applications on PowerPC computers may quit unexpectedly on launch or quit, or dis iBot OS X Support RSS 0 10-15-2008 06:10 PM
How Do You Know When It's Time To Quit The Job? iBot Cartoons for Geeks 0 07-10-2008 08:20 AM
quit any time Qwond Shell Programming and Scripting 5 02-16-2008 05:37 PM
Problem about SMTP 'QUIT' command hcliff UNIX for Advanced & Expert Users 2 12-07-2007 09:13 PM
how to quit from glance yls177 UNIX for Dummies Questions & Answers 2 09-23-2002 08:42 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-06-2009
warlock129 warlock129 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 38
Quit command Overlooked

I am having a problem, I am creating a menu driven system that allows user to interrogate a unix system. It is possible to exit the program from all interfaces of my program except one. The program runs and works fine except the quit function on my "Hardware Utilisation" screen being overlooked and i cant seem to see the reason why this is. The code is as follows:


Code:
#!/bin/bash
#Filename: Assigntest Author: Luke Francis
quit=n
while [ "$quit" = "n" ]
do
  clear
  echo "OPERATOR ADMINISTRATIVE TOOL"
  echo
  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
         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 "B. Back to Main Menu"
         echo "Q. Quit"
         echo
         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
         ;;
       2)clear
         echo "NETWORK CONNECTIVITY"
         echo
         echo "1. NIC Status"
         echo "2. Machine Availability"
         echo "B. Back to Main Menu"
         echo "Q. Quit"
         echo
         echo "Which option do you require?"
         read menunumber4
         case $menunumber4 in
              1)clear
                echo "Information reagrding NIC status can be found below:"
                echo
                /sbin/ifconfig
                echo
                echo "Hit the Enter Key to continue"
                read junk;;
              2)clear
                echo "Available hosts and addresses are shown below:"
                echo
                cat /etc/hosts
                echo
                echo "Hit Enter Key to continue"
                read junk;;
       Q|q)clear
           echo "Are you sure you want to quit? Y/N"
           read choice2
           case $choice2 in
                N|n)clear
                    echo "Hit Enter key to continue"
                    read junk;;
                Y|y)quit=y;;
 *)clear
                sleep 2;;
           esac
           ;;
         esac
          ;;
        3)clear
          echo "PROCESSES"
          echo
          echo "1. Running Processes"
          echo "2. Installed Software"
          echo "B. Back to Main Menu"
          echo "Q. Quit"
          echo
          echo "Which option do you require?"
          read menunumber5
          case $menunumber5 in
               1)clear
                 echo "Current running processes are displayed below"
                 echo
                 ps aux
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               2)clear
                 echo "The software currently installed on this host is:"
                 echo
                 rpm -qa
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
        Q|q)clear
           echo "Are you sure you want to quit? Y/N"
           read choice3
           case $choice3 in
                N|n)clear
                    echo "Hit Enter key to continue"
                    read junk;;
 Y|y)quit=y;;
                  *)clear
                sleep 3;;
           esac
            ;;
         esac
          ;;
        4)clear
          echo "SYSTEM INFORMATION"
          echo
          echo "1. Machine Name"
          echo "2. System Date & Time"
          echo "3. Licensing Information"
          echo "4. Last System Reboot"
          echo "B. Back to Main Menu"
          echo "Q. Quit"
          echo
          echo "Which option do you require?"
          read menunumber6
          case $menunumber6 in
               1)clear
                 echo "The name of the machine is:"
                 uname -m
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               2)clear
                 echo "The current date and time is:"
                 echo
                 date
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               4)clear
                 echo "The last scheduled system reboot was:"
                 echo
                 who -b
                 echo
echo "Hit Enter Key to continue"
                 read junk;;
               B)read junk;;
               Q|q)clear
                   echo "Are you sure you want to quit? Y/N"
                   read choice4
                   case $choice4 in
                   N|n)clear
                       echo "Hit Enter key to continue"
                       read junk;;
                   Y|y)quit=y;;
                     *)clear
                   sleep 4;;
               esac
             ;;
         esac
         ;;
       5)clear
         echo "HARDWARE UTILISATION"
         echo
         echo "1. Unix Filesystem Usage"
         echo "2. RAM Availability"
         echo "3. Swap Space"
         echo "4. CPU Utility"
         echo "Q. Quit"
         echo
         echo "Which option do you require?"
         read menunumber6
         case $menunumber6 in
              1)clear
                echo "Information regarding usage of the Unix filesystem as requested can be found below:"
                echo
                df -h
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              2)clear
                echo "RAM usage information can be found below:"
echo
                cat /proc/meminfo
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              3)clear
                echo "The amount of free and used Swap space is:"
                echo
                cat /proc/meminfo
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              4)clear
                echo "The first column indicates size of CPU run queue"
                echo
                vmstat
                echo
                echo "Hit Enter Key to continue"
                read junk;;
        esac
        ;;
       Q|q)clear
            echo "Are you sure you want to quit? Y/N"
                   read choice5
                   case $choice5 in
                   N|n)clear
                       echo "Hit Enter key to continue"
                       read junk;;
                   Y|y)quit=y;;
                     *)clear
                   sleep 5;;
              esac
              ;;
  esac
done
clear
echo "Thank you for using the Operator Administrative Tool"


The section of the code i feel the problem may stem from has be highlighted red. Can any ammendmants be made directly to my code so i can clearly see where to implement suggested changes. Any help would be appreciated. Thanks.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0