Results 1 to 5 of 5

Thread: YES/NO option in script

  1. #1
    Join Date
    Mar 2014
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 13.10 Saucy Salamander

    YES/NO option in script

    Hi,

    I maked a script to install some programs automatic, but on the end I want an option what shows the option to choose yes or no with the following question: Would you like to reboot the system now? It is recommed.

    If a user choose no there must be shown a message before something else.
    If the user choose yes there must be also a message before something else.

    Can someone tell me how?

  2. #2
    Join Date
    Sep 2010
    Beans
    898

    Re: YES/NO option in script

    Do you want a command-line solution, or a dialog box?

  3. #3
    Join Date
    Mar 2014
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: YES/NO option in script

    In the terminal, that is the command-line right?

  4. #4
    Join Date
    Sep 2010
    Beans
    898

    Re: YES/NO option in script

    Yes, so you want the user to type 'y' or 'n'? There are utilities such as zenity that can be used from a terminal script, which display a dialog box with buttons, and return the user's choice to the script.

  5. #5
    Join Date
    Mar 2014
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: YES/NO option in script

    Quote Originally Posted by Dave_L View Post
    Yes, so you want the user to type 'y' or 'n'? There are utilities such as zenity that can be used from a terminal script, which display a dialog box with buttons, and return the user's choice to the script.
    Yes.

    OK, I got on the end this:
    Code:
    read -r -p "Druk op [Enter] om verder te gaan..." keyclear
    echo "Het word aangeraden het systeem te herstarten...
    Typ sudo reboot om te herstarten of exit om de terminal te sluiten."
    read input
    
    
    if [ "$input" == "reboot" ]; then
        sudo reboot
    elif [ "$input" == "exit" ]; then
        exit
    else
        echo "Dit antwoord is niet gevonden..."
    
    
    fi
    When I enter "exit" the terminal close. When I enter "reboot" the terminal close also but the system doesn't reboot. Also an other answer closes the terminal...
    Last edited by Korkel; March 21st, 2014 at 11:20 AM. Reason: Extra information added.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •