View Single Post
  #1   (View Single Post)  
Old 20th October 2008
neurosis neurosis is offline
Fdisk Soldier
 
Join Date: Jul 2008
Posts: 69
Default torsmo displaying weather question

Ive been reading on other forums "gentoo and ubuntu" that you can get torsmo to display the current weather. It looks rather simple though I dont know anything about programming or shell scripting. Here is a link to the thread.

http://forums.gentoo.org/viewtopic-t...rsmo+tips.html

Here is the code for the script.

Code:
#!/bin/bash
city="DeWitt"
link=USMI0231.html
file=/tmp/weather.txt
location=http://weather.yahoo.com/forecast/$link

lynx -accept_all_cookies -dump $location > $file
begin=`cat -n $file | grep "Currently" | cut -d ' ' -f5`
end=`expr $begin + 40`

head -n $end $file > tmp.t
tail -n 41 tmp.t > $file

case $1 in
   Today)  head -n 6 $file | sed '3d' ;;
   Tomorrow)
      begin=`cat -n $file | grep 'Today Tomorrow' | cut -d ' ' -f5`
      end=`cat -n $file | grep 'Extended' | cut -d ' ' -f5`
      num=`expr $end - $begin - 1`
      end2=`expr $begin + 7`

      head -n $end2 $file > tmp.t
      tail -n 3 tmp.t | sed 's/sky/\n sky/' | sed '4d' ;;
   *) exit ;;
esac

rm tmp.t
rm $file
When I run this I get an error.

Code:
$ ./tweather.sh
expr: syntax error
head: illegal line count -- /tmp/weather.txt
Can anyone offer suggestions as to why this isnt working?
Reply With Quote