PrathvirajFeb 3
An attempt to write a script to notify when a movie is listed online for booking
This is my attempt to write a shell script that sends me an email when a movie is available for booking online.
NOTE: You might want to configure ‘mail’ command SMTP settings on your box to avoid the mail being sent to your spam folder.
This script takes 2 arguments. The first argument is the URL that has to be monitored and the second argument is name of the theater (Or anything that is unique to that theater).
The script scrapes the URL page once in a given interval period and looks for the theater name, and when it’s found it sends an email to the given email ID.
#! /bin/bash
if [ “$#” -ne 2 ]; then
echo “Illegal number of parameters”
echo “USAGE: movieAlert <URL> <KEYWORD>”
exit 1
fi
[email protected]
BODY=$1
SUB=”Hurry up!!!”
IP=$1
QUERY=$2
while true; do
result=`wget -O — $IP -o /dev/null|grep $QUERY|wc -l`
if [ $result -gt 1 ]; then
mail -s “$SUB” “$EMAIL_IDS” <<<”$BODY”
exit 0
fi
sleep 60
done
Originally published at apsotech.blogspot.in.