#!/bin/sh -u # A weather script to show the current temperature in Ottawa. #------------------------------------------------------------------ # Syntax: $0 (no command line arguments used) #------------------------------------------------------------------ # Purpose: # Display the current weather for Ottawa. #------------------------------------------------------------------ # Student Name: Ben Dover # Algonquin EMail Address: abcd0001 # Student Number: 074-210-779 # Course Number: NET2003 # Lab Section Number: 014 # Professor Name: Ian Allen # Assignment Name/Number/Date: This is a sample exercise label # Comment: This is a sample. #------------------------------------------------------------------ # Use standard search path, friendly umask, ASCII collating and sorting. # PATH=/bin:/usr/bin ; export PATH umask 022 LC_COLLATE=C ; export LC_COLLATE # Note the need to quote the URL because of the shell metacharacter. # Save the lynx formatted output in a shell variable for later processing. # url='http://text.weatheroffice.ec.gc.ca/forecast/city_e.html?on-118' page=$( lynx -dump "$url" ) # Note: we should check the contents of $page for errors here ... # Send the saved page contents through grep twice to fetch two lines. # Command substitution captures the line output by grep. # templine=$( echo "$page" | grep -A 1 -e 'Temperature:' | tail -1 ) obsline=$( echo "$page" | grep 'Observed ' ) # Echo the output through tr to compress multiple blanks into one. # echo "$obsline --> $templine" | tr -s ' '