dialog shell script example
#!/bin/bash
# while-menu-dialog: a menu driven system information program
DIALOG_CANCEL=1
DIALOG_ESC=255
HEIGHT=0
WIDTH=0
display_result() {
dialog --title "$1" \
--no-collapse \
--msgbox "$result" 0 0
}
while true; do
exec 3>&1
selection=$(dialog \
--backtitle "System Information" \
--title "Menu" \
--clear \
--cancel-label "Exit" \
--menu "Please select:" $HEIGHT $WIDTH 4 \
"1" "Display System Information" \
"2" "Display Disk Space" \
"3" "Display Home Space Utilization" \
2>&1 1>&3)
exit_status=$?
exec 3>&-
case $exit_status in
$DIALOG_CANCEL)
clear
echo "Program terminated."
exit
;;
$DIALOG_ESC)
clear
echo "Program aborted." >&2
exit 1
;;
esac
case $selection in
0 )
clear
echo "Program terminated."
;;
1 )
result=$(echo "Hostname: $HOSTNAME"; uptime)
display_result "System Information"
;;
2 )
result=$(df -h)
display_result "Disk Space"
;;
3 )
if [[ $(id -u) -eq 0 ]]; then
result=$(du -sh /home/* 2> /dev/null)
display_result "Home Space Utilization (All Users)"
else
result=$(du -sh $HOME 2> /dev/null)
display_result "Home Space Utilization ($USER)"
fi
;;
esac
done
Also in C++:
- select position terminal
- how to install heroku toolbelt on mac
- Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.
- ubuntu uninstall redis
- git already up to date but not
- add python to path
- powershell admin privileges
- change master to main git
- install wine-5.5 ubuntu 20.10
- cancel a merge git
- gradle init java application
- how to change hostname in ubuntu
- how to delet file comand promt linux
- how to install netdata on ubuntu wsl2
- Identities entities in vault hashicorp
- set python3 as default mac
- composer install delete from parameters.yml symfony 3
- connectify alternative for linux
- aws instance agent installation on command line (cloudwatchlogs)
- git borrar rama local y remote
- open file explorer from cmd
- find command in linux
- remove directory from git without deleting
- discard unstaged changes git