Advertisement
cindy_wijaya

File Monitoring MD5 - Convert MYSQL Outbox Table to Send SMS

Sep 6th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. file=/mnt/sda1/data-mysql/mysql/sms/toutbox.MYD
  4. fingerprintfile=/tmp/.bla.md5savefile
  5. while true; do
  6. if [ ! -f $file ]
  7.     then
  8.         echo "ERROR: $file does not exist - aborting"
  9.     exit 1
  10. fi
  11. filemd5=`md5sum $file | cut -d " " -f1`
  12. if [ -z $filemd5 ]
  13.     then
  14.         echo "The file is empty - aborting"
  15.         exit 1
  16.     else
  17.         :
  18. fi
  19. if [ -f $fingerprintfile ]
  20.     then
  21.         savedmd5=`cat $fingerprintfile`
  22.         if [ -z $savedmd5 ]
  23.             then
  24.                 echo "The file is empty - aborting"
  25.                 exit 1
  26.         fi
  27.         if [ "$savedmd5" = "$filemd5" ]
  28.             then
  29.                 :
  30.             else
  31.                 echo "File has been changed"
  32.                 #tambahkan bagian ini
  33.                 eval $(mysql -u root -ppassword sms -N -e "select concat('sms_kirim ',hp,' \"',isi,'\";') from toutbox where hp is not null or hp!=''")
  34.                 mysql -u root -ppassword sms -e "truncate toutbox"
  35.                 # --end--
  36.                 echo
  37.         fi
  38. fi
  39. echo $filemd5 > $fingerprintfile
  40. sleep 1
  41. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement