Keywords: Dialog , kdialog
dailog do not need X services, kdialog need X services
A method (dialog):
#!/bin/bash # using dialog to create a menu temp=$(mktemp -t test.XXXXXX) temp2=$(mktemp -t test2.XXXXXX) function diskspace { df -k > $temp dialog --textbox $temp 20 60 } function whoseon { who > $temp dialog --textbox $temp 20 50 } function memusage { cat /proc/meminfo > $temp dialog --textbox $temp 20 is 50 } the while [ . 1 ] do Dialog --menu " Sys the Admin Menu " 20 is 30 10 . 1 " Display Disk Space " 2 \ " Display Users " . 3 " Display Memory Usage " 0 " the Exit " 2 > $ temp2 of note here # redirection of different kdialog IF [$? -eq 1 ] the then BREAK fi Selection = $ ( CAT $ temp2) Case $selection in 1) diskspace ;; 2) whoseon ;; 3) memusage ;; 0) break ;; *) dialog --msgbox "Sorry, invalid selection" 10 30 esac done rm -f $temp 2> /dev/null rm -f $temp2 2> /dev/null
Achieve results:
Method II ( kdialog):
Set X service address (WindowsIP: 192.168.1.3):
[Root @ ORACLE ~] # export DISPLAY = 192.168.1.3: 0.0 (depends on the local computer)
[root@ORACLE ~]# export|grep DISPLAY
declare -x DISPLAY="192.168.1.3:0.0"
[root@ORACLE ~]#
script:
#!/bin/bash # using kdialog to create a menu temp=$(mktemp -t temp.XXXXXX) temp2=$(mktemp -t temp2.XXXXXX) function diskspace { df -k > $temp kdialog --textbox $temp 1000 10 } function whoseon { who > $temp kdialog --textbox $temp 500 10 } function memusage { cat /proc/meminfo > $temp kdialog --textbox $temp 300 500 } the while [ . 1 ] do kdialog --menu " Sys the Admin Menu " " . 1 " " Display diskspace " " 2 " " Display \ # Note that no need to define the length and breadth Users " " . 3 " " Display Memory Usage " " 0 " " Exit " >$ temp2 # Note that redirection dialog with different IF [$? -eq 1 ] the then BREAK fi Selection = $ ( CAT $temp2) case $selection in 1) diskspace ;; 2) whoseon ;; 3) memusage ;; 0) break ;; *) kdialog --msgbox "Sorry, invalid selection" esac done
Achieve results: