i want to write a simple quick and dirty script that makes a whois query and emails me when the word SUSPENDED doesn't occur in the output. i've got the basics done. i just need to know how to join two bits i've got together so that the second bit gets run conditionally.
whois thedomain.com | grep -q SUSPENDED
returns 0 if the word SUSPENDED is part of the output of the whois lookup.
message.txt | sendmail email@example.com
sends me an email containing the contents of the file message.txt (can't work out how to send a message from the command line rather than a file pointed to from the command line but that really doesn't matter)
so, how can i conditionally run 'message.txt | sendmail firstname.lastname@example.org' based on the response from 'whois thedomain.com | grep -q SUSPENDED' somehow in a script?
having done the script i'm going to have it trigerred every day by a cron job.
i'm using mac os x 10.3 so therefore unix.