- snowday.sh
- 2007 year 1 month 22 day Monday 19:50:15 MDT
- #!/bin/bash
- #snow delay/closing parser program
- #Kyle Bassett, Chris Merck
- clear
- echo "SNOWDAY Auto-TXTer V 0.1"
- echo "By Kyle Bassett and Chris Merck"
- #----DIR location for snowday----:
- cd ~/snowday
- #this file must have an empty last line
- file_txt_clients="./email_clients"
- http_vtsd="URL OF WEBSITE TO BE PARSED"
- #time to wait to rec'v and parse file
- timedelay=60
- #time to stop txt msgs
- timestopdelay=100000
- #txtmsg body:
- txtbody="School District-KBass's SnoInfo-reply STOP.SNOW to cancel. Have fun! `date`"
- #infinite loop, stop for delay/closing
- while [ "" = "" ]
- do
- #----------get page to parse-----------
- lwp-download $http_vtsd ./vtsd
- #----------parse page------------------
- closed=`cat ./vtsd/index.html | grep -i closed | wc -l | cut -f 2`
- delay=`cat ./vtsd/index.html | grep -i delay | wc -l | cut -f 2`
- msg=""
- #for debugging:
- #msg="no delay / closing yet!"
- if [ $delay = 1 ]
- then
- msg="Delayed Opening"
- echo "Delayed Opening"
- timedelay=$timestopdelay
- fi
- #closed=0
- #msgcountperday=2
- if [ $closed = 1 ]
- then
- timedelay=$timestopdelay
- msg="School is Closed"
- echo "School is Closed"
- fi
- if [ "" != "$msg" ]
- then
- #determine the number of lines in the file
- #this is the number of ppl to send to,
- # each line being another email address or vtext addr
- lines=`wc -l $file_txt_clients | cut -d " " -f 1`
- echo "email_clients contains $lines clients."
- lineindex=$lines
- until [ "$lineindex" = "0" ]
- do
- #send the top line in a text message
- email=`tail -n $lineindex $file_txt_clients | head -n 1`
- #create command file to carry out SMTP transaction
- echo "HELO ksb" > tmp
- echo "MAIL FROM: snowday@cipercast.net" >> tmp #you can make this anything!
- echo "RCPT TO: $email" >> tmp
- echo "DATA" >> tmp
- echo "Subject: $msg" >> tmp
- echo $txtbody >> tmp
- echo "." >> tmp
- echo "QUIT" >> tmp
- #send message over an smtp relay
- netcat smtp.find_your_own_mail_relay.net 25 < tmp
- #update our index number
- let "lineindex -= 1"
- echo "lines left: $lineindex"
- done
- fi
- rm ~/snowday/vtsd/index.html
- sleep $timedelay
- done
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.