老妖怪的二三事
http://bbs.ainic.tw/

Check OUI list, if changed than mail to JoeChen
http://bbs.ainic.tw/viewtopic.php?f=25&t=229
第 1 頁 (共 1 頁)

發表人:  JoeChen [ 2008-12-02, 11:49 ]
文章主題 :  Check OUI list, if changed than mail to JoeChen

path: /home/users/joechen/workshop/get_oui.sh

code:
-- Top of the code --
echo "Check OUI data..."
sleep 1
/bin/mv ./oui_ok.txt ./oui_ok.txt.old

echo "移除舊有的原始 OUI 列表..."
sleep 1
/bin/rm ./oui.txt

echo "取得原始 OUI 列表, 並取出必要資訊..."
sleep 1
/usr/bin/wget http://standards.ieee.org/regauth/oui/oui.txt
/bin/awk '$0 ~ /^0|^1|$2/' ./oui.txt > ./oui_tmp1.txt
/bin/sed /\(base\ 16\)/d ./oui_tmp1.txt > ./oui_tmp2.txt
/bin/sed s/\(hex\)/\ / ./oui_tmp2.txt > ./oui_tmp3.txt
/bin/sed s/\ \ // ./oui_tmp3.txt > ./oui_tmp4.txt
/bin/sed s/\ \ \ \// ./oui_tmp4.txt > ./oui_ok.txt
/bin/rm -f *tmp[1-4]*.txt

echo "比對新舊 OUI 資料是否相符..."
sleep 1
/usr/bin/diff ./oui_ok.txt.old ./oui_ok.txt > ./wc.txt

echo "查看 OUI 資料是否有異動, 若有, 將寄信給 Joe Chen..."
sleep 1
# check if out txt file is different
if [ -s wc.txt ]; then
echo "Check the different with above information..." >> ./wc.txt
mail -s "OUI 資料有異動" joechen@niu.edu.tw < ./wc.txt
echo "OUI 資料有異動, 已發信通知 Joe Chen"
else
echo "OUI 資料沒有異動, 不需通知"
exit 0
fi
-- Bottom of the code --

crontab -e
0 */6 * * * /home/users/joechen/workshop/get_oui.sh

第 1 頁 (共 1 頁) 所有顯示的時間為 UTC + 8 小時
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/