1
0

weather 795 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/rc
  2. rfork e
  3. DEFAULT=ewr
  4. fn usage{
  5. echo 'usage: weather 3-letter-city-code' >[1=2]
  6. echo 'for a list of cities in new york, say' >[1=2]
  7. echo ' weather ny' >[1=2]
  8. exit usage
  9. }
  10. switch($#*){
  11. case 0
  12. arg=$DEFAULT
  13. if(~ $#weather 1)
  14. arg=$weather
  15. case 1
  16. arg=$1
  17. case *
  18. usage
  19. }
  20. switch($arg){
  21. case [a-zA-Z][a-zA-Z][a-zA-Z]
  22. script=('' '' 'C' '4' '1' '1' $arg '' '' '' '' 'X')
  23. case [a-zA-Z][a-zA-Z]
  24. script=('' '' 'C' '4' '1' '3' $arg '' '' '' '' 'X')
  25. case *
  26. usage
  27. }
  28. {
  29. for(i in $script)
  30. echo $i
  31. } |
  32. con -nrl tcp!rainmaker.wunderground.com!telnet |
  33. sed -n '/Enter .-letter .* code:/,/CITY FORECAST MENU/p' |
  34. sed 's/Enter .-letter .* code: //' |
  35. sed 's/ Press Return to continue, M to return to menu, X to exit: //' |
  36. grep -v 'CITY FORECAST MENU' |
  37. tr -d ' ' |
  38. sed 's/ *$//' |
  39. uniq