quit command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mubs
    New Member
    • Mar 2007
    • 77

    quit command

    i have the following script.. but i cant get the quit command working...

    can some1 help

    quit = n

    host="$(hostnam e)"
    todaysdate="$(d ate)"
    lastboot="$(las t reboot)"
    licensinginfo=" $(uname -a)"

    currenthardware info="$(info)"
    diskspace="$(df )"

    IPAddress="$(/sbin/ifconfig)"

    while [ "$quit" = "n" ]
    do
    clear

    echo "1. General machine information"
    echo "2. Machine hardware/software information"
    echo "3. Network related information"
    echo "4. User related information"
    echo "Q. Quit"

    echo "Please make your selection"

    read menunumber
    if [ $menunumber -eq 1 ]
    then
    echo " The hostname is $host"
    echo " The date is $todaysdate"
    echo " The system last rebooted is $lastboot"
    echo " Licensing info:$licensing info"

    echo " Press Enter Key to continue"
    read ;


    else if [ $menunumber -eq 2 ]
    then
    echo " Current Hardware: $currenthardwar einfo"
    echo " Disk space: $diskspace"

    echo " Press Enter Key to continue"
    read ;


    else if [ $menunumber -eq 3 ]
    then
    echo "IP Address: $IPAddress"

    echo " Press Enter Key to continue"
    read ;

    else if Q|q) quit=y;
    *) echo "Invalid Choice"



    fi

    fi

    fi

    sleep 1
    done
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Rather than having a variable, and checking that again and again, just check for the quit command, and exit.

    Comment

    • Mubs
      New Member
      • Mar 2007
      • 77

      #3
      Originally posted by Motoma
      Rather than having a variable, and checking that again and again, just check for the quit command, and exit.
      and how can i do that...

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        inside the while loop:
        Code:
        else if Q|q) exit;

        Comment

        • Mubs
          New Member
          • Mar 2007
          • 77

          #5
          Originally posted by Motoma
          inside the while loop:
          Code:
          else if Q|q) exit;
          i have tried that it stil doesnt work

          Comment

          • Motoma
            Recognized Expert Specialist
            • Jan 2007
            • 3236

            #6
            Originally posted by Mubs
            i have tried that it stil doesnt work
            What happens?
            Are you sure that section of code is actually being called? Put some echo statements in choice sections of code to make sure the flow is going the way you think it should be going.

            Comment

            Working...