#!/bin/sh -u # demonstrate the use of the shell "read" built-in command # ----- # Syntax: $0 (no arguments) # ----- # Purpose: # Prompt for a file name and a userid. # Display the given filename on the terminal of the given userid. # ----- # -IAN! idallen@idallen.ca # Use standard search path, friendly umask, ASCII collating and sorting. # Set the language and character set to be ASCII/C standard. # PATH=/bin:/usr/bin ; export PATH LC_COLLATE=C ; export LC_COLLATE LANG=C ; export LANG umask 022 # prompt on stderr and read the file name and userid from standard input # quick-exit the script if the user enters EOF (and the read returns non-zero) # echo 1>&2 "$0: Enter a file name and a userid on one line:" read filename userid || exit 1 # send the file to the given userid # write "$userid" <"$filename" # The script exits with the return status of the last command executed.