diff --git a/server_weather.sh b/server_weather.sh index dce019a..e38f9b7 100755 --- a/server_weather.sh +++ b/server_weather.sh @@ -25,12 +25,12 @@ get_weather() { LAT=$(echo "$COORDS" | awk -F , '{print $1}') LON=$(echo "$COORDS" | awk -F , '{print $2}') - url="https://api.openweathermap.org/data/2.5/weather\?lat=$LAT\&lon=$LON\&appid=$API_KEY\&units=imperial" + url="https://api.openweathermap.org/data/2.5/weather?lat=$LAT&lon=$LON&appid=$API_KEY&units=$UNITS" res=$(curl --silent -fL "$url") echo "$res" } -while getopts "c:s:z:" opt; do +while getopts "c:s:z:u:" opt; do case "$opt" in 'c' ) COORDS="$OPTARG" @@ -41,6 +41,8 @@ while getopts "c:s:z:" opt; do 'z' ) ZIPCODE="$OPTARG" ;; + 'u' ) + UNITS="$OPTARG" '?' ) echo "ERROR: UNRECOGNZIED ARGUMENT" exit 1