#!/bin/sh -u # wait until userid signs on, then print a message and exit. # Syntax: $0 userid # Purpose: # Wait until the given userid signs on, then print a message and exit. # The script also exits if $USER (the person running the script) # is no longer signed on. (The script exits when $USER logs off.) # This could be run in the background. # -IAN! idallen@idallen.ca # Use standard search path, friendly umask, ASCII collating and sorting. # PATH=/bin:/usr/bin ; export PATH umask 022 LC_COLLATE=C ; export LC_COLLATE # validate the number of inputs and make sure input isn't empty # if [ $# -ne 1 ] ; then echo 1>&2 "$0: Expecting 1 userid arg; found $# ($*)" exit 1 fi if [ -z "$1" ] ; then echo 1>&2 "$0: Empty command line argument; nothing done" exit 1 fi # Keep looking for $1 as long as $USER is still signed on. # while ! who | grep "$1" ; do if ! who | grep "$USER" >/dev/null ; then echo 1>&2 "$0: Userid $USER is no longer signed on." exit 1 fi sleep 30 done echo "$0: Userid $1 is now signed on." exit 0