-1
我已經嘗試編寫一個shell腳本,在磁盤使用率達到70%時提醒管理員。我想在python將shell腳本轉換爲python程序
#!/bin/bash
ADMIN="[email protected]"
INFORM=70
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 」 」 $6 }’ | while read output;
do
use=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’)
if [ $use -ge $INFORM ]; then
echo 「Running out of space \」$partition ($use%)\」 on $(hostname) as on $(date)」 |
mail -s 「DISK SPACE ALERT: $(hostname)」 $ADMIN
fi
done
你嘗試過什麼? StackOverflow不在這裏只爲你寫代碼。 – Amber 2013-02-11 06:14:49
好的目標。哪些部分不知道如何處理Python?如果答案是「全部」,那麼對你來說這可能不是一個好主意。你只會交易一件你不知道的東西,你不知道的東西。 – 2013-02-11 06:24:57
我是新來的python和問題獲得一點的指導和當然不是整個代碼。所以如果我的問題看起來如此苛刻,請原諒我 – manali23 2013-02-11 06:30:02