Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash similiar to choice in cmd

#!/bin/bash

HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="Backtitle here"
TITLE="Title here"
MENU="Choose one of the following options:"

OPTIONS=(1 "Option 1"
         2 "Option 2"
         3 "Option 3")

CHOICE=$(dialog --clear 
                --backtitle "$BACKTITLE" 
                --title "$TITLE" 
                --menu "$MENU" 
                $HEIGHT $WIDTH $CHOICE_HEIGHT 
                "${OPTIONS[@]}" 
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
            echo "You chose Option 1"
            ;;
        2)
            echo "You chose Option 2"
            ;;
        3)
            echo "You chose Option 3"
            ;;
esac
Source by askubuntu.com #
 
PREVIOUS NEXT
Tagged: #bash #similiar #choice #cmd
ADD COMMENT
Topic
Name
5+6 =