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_IDS="username@mail.com"
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

8 comments: Leave Your Comments

  1. It’s really amazing that we can record what our visitors do on our site. Thanks for sharing this awesome guide. I’m happy that I came across with your site this article is on point,thanks again and have a great day. Keep update more information..

    Best Interior Designers in Chennai
    Interior Designers in Chennai

    ReplyDelete
  2. It’s the best time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you few interesting things or suggestions.You can write next articles referring to this article. I desire to read even more things about it..
    Java Training in Chennai
    Oracle Apps Training in Chennai
    PHP Training in Chennai

    ReplyDelete
  3. This is an awesome post.
    Really very informative and creative contents.
    These concept is a good way to enhance the knowledge.

    Hadoop Training in Chennai

    ReplyDelete