All pastes #2121639 Raw Edit

weather.sh

public shellscript v1 · immutable
#2121639 ·published 2012-02-26 07:24 UTC
rendered paste body
#!/bin/bashRSS_URL=http://rss.wunderground.com/auto/rss_full/global/stations/33008.xml?units=metricBASE_DIR=~/scripts/weatherTEMPFILE=$BASE_DIR/temp.txtcurl $RSS_URL 2>/dev/null |awk '{gsub("Temperature: ", "", $0);gsub("Humidity", "Влажность", $0);gsub("Pressure", "Давление", $0);gsub("Conditions:", "", $0);gsub("hPa", "гПа", $0);gsub("Falling", "Снижается", $0);gsub("Steady", "Устойчивое", $0);gsub("Rising", "Повышается", $0);gsub("Clear", "A", $0);gsub("Partly Cloudy", "b", $0);gsub("Mostly Cloudy", "d", $0);gsub("Snow", "k", $0);gsub("Wind Direction", "Ветер", $0);gsub("Overcast", "d", $0);gsub("Mist", "e", $0);gsub("Light Rain", "g", $0);gsub("SW", "ЮЗ", $0);gsub("SE", "ЮВ", $0);gsub("E", "В", $0);gsub("W", "З", $0);gsub("NW", "СЗ", $0);gsub("NE", "СВ", $0);gsub("N", "С", $0);gsub("S", "Ю", $0);gsub("&deg;", "°", $0);gsub("Wind Speed", "Скорость ветра", $0);n=split($0,array,"CDATA");n=split(array[2],array,"[");n=split(array[2],array,"|");split(array[6],ar,"<");array[6]=ar[2];temp = array[1];array[1]=array[4];array[4]=temp;for (i=1;i<n;i++) {printf("%s\n",array[i]);}}'|cat > $TEMPFILE#cat $TEMPFILEinputfile=$1let count=0while read LINE; do    ARRAY[$count]=$LINE    ((count++))done < $TEMPFILEecho ${ARRAY[0]} > $BASE_DIR/cond.txtecho ${ARRAY[3]} > $BASE_DIR/temp.txtecho ${ARRAY[1]}echo ${ARRAY[2]}exit 0