Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/gawk -f
- {
- location=$0;
- gsub(/ /,"+",location);
- pipe="curl -s http://weather.gladstonefamily.net/site/search?site=" location;
- RSsave=RS;
- RS="<[lL][iI]>";
- while(pipe |getline) {
- if($0 ~ /href="\/site\/[^"]/ && $0 !~ /\[no data\]/) {
- site=gensub(/.*href="\/site\/([^"]+).*/,"\\1", "g");
- station=gensub(/.*href="[^\"]+">([^<]+).*/,"\\1", "g");
- close(pipe);
- pipe="curl -s http://weather.gladstonefamily.net/cgi-bin/wxobservations.pl?site=" site "&days=1";
- RS="\n";
- FS=",";
- while(pipe |getline) { } #discard all but last data line
- CONVFMT="%.1f";
- print "weather for " station ": " $2 " mbar, " $3 "F/" ($3-32)/1.8 "C/" ($3+459.67)/1.8 "K";
- print "wind " $6 "mph / " $6*1.60934 "kph / " $6*0.44704 "m/s, " $7 " degrees";
- break;
- }
- }
- close(pipe);
- RS=RSsave;
- }
Add Comment
Please, Sign In to add comment