Suggestion: use "dialog" to create some nice menus
Posted: 07.12.2013, 20:50
dialog can be used to create menus and input boxes in the shell. These dialogs can be navigated with the mouse and the cursor keys, the number keys, or by typing the first letter of each line.
I have prepared a sample skript of what it could look like:
This could even make the maintenance easier, since dialog can return the needed variables.
Just make sure, that "dialog" is installed. Debian uses a replacement with a silly name instead (http://packages.debian.org/wheezy/whiptail).
Greetings,
Hartmut Buhrmester
I have prepared a sample skript of what it could look like:
- Code: Select all
#!/bin/bash
# Sample skript for a possible usage of "dialog"
OS_sys=$(dialog --no-cancel --stdout --menu "Please select your OS" 0 0 0 \
"wxp-x86" "Windows XP" \
"wxp-x64" "Windows XP 64-bit" \
"w2k3-x86" "Windows Server 2003" \
"w2k3-x64" "Windows Server 2003 64-bit" \
"w60-x86" "Windows Vista / Server 2008" \
"w60-x64" "Windows Vista / Server 2008 64-bit" \
"w61-x86" "Windows 7" \
"w61-x64" "Windows 7 / Server 2008 R2 64-bit" \
"w62-x86" "Windows 8.0" \
"w62-x64" "Windows 8.0 / Server 2012 64 bit" \
"w63-x86" "Windows 8.1" \
"w63-x64" "Windows 8.1 64 bit" \
"all-x86" "All 32 bit" \
"all-x64" "All 64 bit" )
lang=$(dialog --no-cancel --stdout --menu "Please select your OS language" 0 0 0 \
"enu" "English" \
"deu" "German" \
"nld" "Dutch" \
"esn" "Spanish" \
"fra" "French" \
"ptg" "Portuguese" \
"ptb" "Portuguese (Brasil)" \
"ita" "Italian" \
"rus" "Russian" \
"plk" "Polish" \
"ell" "Greek" \
"csy" "Czech" \
"dan" "Danish" \
"nor" "Norwegian" \
"sve" "Swedish" \
"fin" "Finnish" \
"jpn" "Japanese" \
"kor" "Korean" \
"chs" "Chinese" \
"cht" "Chinese (Taiwan)" \
"hun" "Hungarian" \
"trk" "Turkish" \
"ara" "Arabic" \
"heb" "Hebrew" )
params=$(dialog --no-cancel --stdout --checklist "Select your download options" 0 0 0 \
"excludesp" "Exclude Service Packs" on \
"dotnet" "Download .Net framework" on \
"msse" "Download Microsoft Security Essentials files" off \
"wddefs" "Download Microsoft Windows Defender definition files" off \
"makeiso" "Create ISO-Image after download" on )
http_proxy=$(dialog --backtitle "WSUS Offline Update" --title "Proxy selection" --no-cancel --stdout --inputbox "Please specify your proxy (default: none, http://[username:password@]<server>:<port>])" 0 0)
dialog --backtitle "WSUS Offline Update" --title "Summary" --yesno "Your Choice \n\n\
System: $OS_sys \n\
Language: $lang \n\
Parameter: $params \n\
Proxy: $http_proxy \n\n\
Do you wish to download now?" 0 0
# Possible return status in $?
# 0 = OK-Button
# 1 = Cancel-Button
# 255 = Escape-Key
case $? in
0)
echo "OK";;
1)
echo "Cancel pressed.";;
255)
echo "ESC pressed.";;
esac
This could even make the maintenance easier, since dialog can return the needed variables.
Just make sure, that "dialog" is installed. Debian uses a replacement with a silly name instead (http://packages.debian.org/wheezy/whiptail).
Greetings,
Hartmut Buhrmester