Advertisement
metalx1000

doorbell server CGI code

Apr 4th, 2017
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Content-type: text/html"
  3. echo ""
  4. echo 'Bell Rang!!!'
  5. echo ""
  6. echo ""
  7. img="$(date +%s)"; #get time/date stamp for images
  8. let h="$(date +%H)"; #get current hour
  9.  
  10. #Create log file
  11. echo "====================" >> /tmp/doorbell.log
  12. date >> /tmp/doorbell.log
  13. echo "Hour: $h" >> /tmp/doorbell.log
  14.  
  15. #if it's between 8AM and 8PM ring bell
  16. if [[ "$h" -ge 8 ]] && [[  "$h" -lt 22 ]]
  17. then
  18.   echo "Rang..." >> /tmp/doorbell.log
  19.   wget -q "<url to mail server>" -O /dev/null &
  20.   mplayer bell.mp3 > /dev/null &
  21.   wget -q "<url to second computer>" -O /dev/null &
  22.   #set ip video 9100a to correct camera
  23.   wget --user=<user> --password=<password> "http://<ip address to camera server>/SetChannel.cgi?Channel=2" -O /dev/null
  24. fi
  25.  
  26. #take 4 photos and upload them
  27. for i in `seq 1 4`
  28. do
  29.   wget --user=<user> --password=<password> "http://<ip address to camera server>/Jpeg/CamImg.jpg" -O "../imgs/${img}_${i}.jpg" &&
  30.   curl -X POST -F "file=@../imgs/${img}_${i}.jpg" "https://<url for server>/upload.php" -o /dev/null
  31.   sleep 1
  32. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement