Chinaunix首页 | 论坛 | 博客
  • 博客访问: 272096
  • 博文数量: 42
  • 博客积分: 2718
  • 博客等级: 少校
  • 技术积分: 467
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-19 10:23
个人简介

青 田 酒 店 服 务 小 姐 价 格 186-6531-7773

文章分类

全部博文(42)

文章存档

2011年(36)

2010年(6)

分类: LINUX

2011-06-20 17:10:26

  1. #!/bin/sh

  2. function echo_help()
  3. {
  4.     echo "Usage:"
  5.     echo "sh mailto.sh -to mailaddr -file messagefilename [-from frommailaddr] [-subject mailsubject] [-fname shownam    e] [-tname toshowname]"
  6. }

  7. email="to@toaddress.com"
  8. emailname="cmtools monitor"
  9. messagebody="tmp.tmp"
  10. from="from@fromaddress.com"
  11. fromname="cmtools monitor"
  12. subject="cmtools running statistic report"

  13. until [ $# -eq 0 ]
  14. do
  15. tmpV=$1

  16. if [ $tmpV = "-from" ] ; then
  17. shift
  18. tmpV=$1
  19. from=$tmpV
  20. elif [ $tmpV = "-to" ] ; then
  21. shift
  22. tmpV=$1
  23. email=$tmpV
  24. elif [ $tmpV = "-subject" ] ; then
  25. shift
  26. tmpV=$1
  27. subject=$tmpV
  28. elif [ $tmpV = "-file" ] ; then
  29. shift
  30. tmpV=$1
  31. messagebody=$tmpV
  32. elif [ $tmpV = "-fname" ] ; then
  33. shift
  34. tmpV=$1
  35. fromname=$tmpV
  36. elif [ $tmpV = "-tname" ] ; then
  37. shift
  38. tmpV=$1
  39. emailname=$tmpV
  40. elif [ $tmpV = "--help" -o $tmpV = "-h" ] ; then
  41. echo_help
  42. exit 1
  43. fi

  44. shift
  45. done

  46. if ! test -f ${messagebody} ; then
  47. echo "${messagebody} not exists!"
  48. echo_help
  49. exit 2
  50. fi

  51. echo "begin send..."

  52. echo -e "To: \"${emailname}\" <${email}>\nFrom: \"${fromname}\" <${from}>\nSubject: ${subject}\n\n`cat ${messagebody}`" | /usr/sbin/sendmail -t

  53. echo "send OK."

另外一个维护脚本:

 

  1. echo > old.txt
  2. echo > new.txt
  3. while true
  4. do
  5. echo $$ > pid.txt
  6. ./check > new.txt
  7. #data=`cat new.txt`

  8. if [ -s new.txt ]
  9. then

  10.     res=`diff new.txt old.txt`
  11.     if ! [ -z $res ]
  12.     then
  13.         ./mail.sh -to jigang.djg@taobao.com -file new.txt
  14.         cat new.txt > old.txt
  15.     fi
  16. else
  17.         #res=`cat old.txt`
  18.         if [ -s old.txt ]
  19.         then
  20.             #echo "every thing is ok" > new.txt
  21.             #./mail.sh -to jigang.djg@taobao.com -file new.txt
  22.             echo > new.txt
  23.             echo > old.txt
  24.         fi
  25. fi
  26. sleep 600
  27. done
阅读(1925) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~