[Bash shell] 纯文本查看 复制代码
#!/bin/bash
temp=`mktemp -t temp.XXXXXX`
temp2=`mktemp -t temp.XXXXXX`
function diskspace {
df -h > $temp
zenity --text-info --title "Disk space" --filename=$temp --width 750 --height 50
}
function whois {
whoami > $temp
zenity --text-info --title "Who am i" --filename=$temp --width 760 --height 40
}
function memusage {
cat /proc/meminfo > $temp
zenity --text-info --title "memory usage" --filename=$temp --width 300 --height 500
}
while [ 1 ]
do
zenity --list --radiolist --title "System Admin" --column "Select" --column "Menu Item" FALSE "Disk space" FALSE "Who am i" FALSE "Memory usage" FALSE "Exit" > $temp2
if [ $? -eq 1 ]
then
break
fi
selection=`cat $temp2`
case $selection in
"Disk space")
diskspace ;;
"Who am i")
whois ;;
"Memory usage")
memusage ;;
"Exit")
break ;;
*)
zenity --info "Sorry, wrong selection"
esac
done