#!/bin/bash # /usr/bin/weatherget # simple bash weather script by sev url=ftp://weather.noaa.gov/data/forecasts/city/mn/bemidji.txt text2wave=/usr/bin/text2wave curl=/usr/bin/curl goodbye="Thank you for listening to our weather service. Have a nice day. Drive safely." #First we get the text file $curl -s $url > /tmp/weather.txt #Copy off the first 5 lines and store them in a seperate file head -n 5 /tmp/weather.txt > /tmp/weather_head.txt #Delete the First two annoying lines in the head sed -e '1,2d' /tmp/weather_head.txt > /tmp/weather_move.txt mv /tmp/weather_move.txt /tmp/weather_head.txt #Delete the first 5 lines, delete the . infront of each following line sed -e '1,5d' /tmp/weather.txt | sed -e 's/^.\(.*\)/\1/' > /tmp/weather.txt #Now we append the two files together cat /tmp/weather.txt >> /tmp/weather_head.txt mv /tmp/weather_head.txt /tmp/weather.txt #Text to speach $text2wave /tmp/weather.txt -F 8000 -o /tmp/weather.wav #Tell our caller to have a nice day echo $goodbye | $text2wave -F 8000 -o /tmp/goodbye.wav Then, in extensions.conf: exten => 557,1,Answer exten => 557,2,Wait(1) exten => 557,3,Playback(/tmp/weather); exten => 557,4,Wait(1) exten => 557,3,Playback(/tmp/goodbye); exten => 557,5,Hangup