#!/bin/sh -u # DAT2333 - Fall 2000 - Unix Lab 5 - Script B - final copy. # It prompts you for a name, then echoes the name and a wakeup message, # then sends that wakeup message to that person. # -IAN! idallen@ncf.ca # We loop until the user types one of the many "quit" keywords: # This should be a do/while loop; but, sh doesn't have one. # leave=no while [ "$leave" = "no" ] do # Get some input and echo it back to the user. # echo " " echo "Enter the name: \c" read input echo "You entered: $input" # Select the words to send and the userid recipient based on the input. # userid="" # start with empty userid case "$input" in me) words="Wakie Wakie!" userid="$USER" ;; a|alex) words="Yooo Hoooo!" userid=bbbb2222 ;; b|bobby) words="Wake Up!" userid=aaaa1111 ;; c|chris) words="Think Fast!" userid=cccc3333 ;; q|quit|x|exit|bye|leave|aurevoir|dosvedanja) leave=yes ;; *) echo "Unrecognized input: $input" echo "Please enter a recognized name." ;; esac # If we entered a recognized name, $userid is set. # Echo the words and userid, then send the message. # Check for a good return status from the sending operation. # if [ "$userid" ] then echo "Sending $words to \"$input\" (userid $userid)." if banner "$words" | write $userid then echo "Message sent." else echo " " echo "An error ocurred when sending to $userid." fi fi done