#!/usr/bin/env bash # # Checks when the Bat Bone is in stock again useragent1="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500 .45 Safari/537.36" useragent2="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0" url="http://shop.flitetest.com/multirotors/bat-bone-tri-370-kit/" error="Product is out of stock" recipient="oli@lugh.ch" # Shuffle User Agent rnd_ua=$(shuf -i 1-2 -n 1) if [ $rnd_ua = 2 ]; then ua=$useragent2 else ua=$useragent1 fi curl_cmd=$($(which curl) -s -A "$ua" $url | grep -c "$error") if [ $curl_cmd -lt 1 ]; then echo -e "$(date)\n$url is available again!" | mail -s "In stock again ($url)" $recipient fi