-------------------------- Shell programming practice - Weather scripts -------------------------- -Ian! D. Allen idallen@idallen.ca Scripts must start with a correct DAT2330 preamble and assignment label. ------ Part I - datsubmit 25 ------ Write an executable shell script that prompts for a city code and then fetches the temperature for that city and displays it: $ ./temp25.sh ./temp25.sh: Enter city code: yow The temperature at yow is 5°C $ ./temp25.sh >out ./temp25.sh: Enter city code: yow $ cat out The temperature at yow is 5°C Note that the prompt must not appear on standard output. ------- Part II - datsubmit 26 ------- Modify the script to display the city code in UPPER CASE: $ ./temp26.sh ./temp26.sh: Enter city code: yow The temperature at YOW is 5°C -------- Part III - datsubmit 27 -------- Modify the script to also fetch and display the city name: $ ./temp27.sh ./temp27.sh: Enter city code: yow The temperature at YOW Ottawa North (Kanata - Orleans) is 5°C Hint: Find a pattern that always appears on the same line as the city name. Capture that line, then split it to get just the city part. Optional: Compress repeated blanks into one single blank using "tr". ------- Part IV - datsubmit 28 ------- Modify the script to do three city codes at once (no loop): $ ./temp28.sh ./temp28.sh: Enter three city codes separated by blanks: yow yph yul YOW Ottawa North (Kanata - Orleans) 5°C YPH Inukjuak 1°C YUL Montréal 6°C Note: You do not have to check for missing city input yet. You do not need to do a loop; repeat the code for each city. ------ Part V - datsubmit 29 ------ Modify the script to put the three city codes in alphabetical order: $ ./temp29.sh ./temp29.sh: Enter three city codes separated by blanks: yul yow yph YOW Ottawa North (Kanata - Orleans) 5°C YPH Inukjuak 1°C YUL Montréal 6°C Hint: You can't sort things unless the things are on separate lines. Put the things on separate lines and then sort them. Find a way to pick out the individual words after you have sorted them.