Zenity在bash脚本中不起作用

时间:2015-04-27 07:21:35

标签: bash ubuntu zenity

以下脚本未按预期工作。我执行它时,Zenity GUI窗口根本没有弹出。我无法找出我犯错误的地方。

相同的脚本在RedHat中显示Zenity结果。

export XAUTHORITY=/home/local/$primaryuser/.Xauthority
ALERT=10
df -h|grep -i dev|grep -vE '^Filesystem|proc|none|tmpfs|udev' |awk '{print $1 " " $5 " " $6}' |while read output
do
partition=$(echo $output | awk '{print $1}')
usage=$(echo $output | awk '{ print $2}' | cut -d'%' -f1)   
filesystem=$(echo $output | awk '{print $3}')
if [ $usage -gt $ALERT ]
then
DISPLAY=:0.0 zenity --question --title "$partition is almost full" --text "Do you want to check the highly space utiized files ?"
if [ $? == 0 ]
then 
find / -xdev -type f -ls|sort -nrk 7 |head -15 2>/dev/null |DISPLAY=:0.0 zenity --text-info --title "Top 15 disk space utilized files" --width 1000 --height 500
else
DISPLAY=:0.0 zenity --info --text "Details sent to your Inbox in email"
mailx -s "MailAlert: $partition ($filesystem) is running out of diskspace in `hostname`." $primaryuser << EOF

$filesystem usage is $usage% .Please find the below details to identify which files are utilizing high diskspace and take necessary actions.

`find $filesystem -xdev -type f -ls|sort -nrk  7|head -15 2>/dev/null`  

SYSTEM INFO:
$hardware

You are receiving this email because $primaryuser appears to be the primary user of `hostname`.If you have already reduced the diskspace you can ignore this message.
EOF
fi
else
exit 1
fi
done

0 个答案:

没有答案