periodically checks for the removal of the specified file
Add a -n option to waitfor that inverts the monitoring function. So
waitfor -n sandy
checks for sandy logging off the system, and
waitfor -n -f /tmp/dataout &
#
# Wait until a specified user logs on -- version 3
#
# Set up default values
mailopt=FALSE
interval=60
waitfile=""
negate=FALSE
# process command options
while getopts "f:nmt:" option
do
case "$option"
in
f) waitfile=$OPTARG ;;
n) negate=TRUE ;;
m) mailopt=TRUE ;;
t) interval=$OPTARG ;;
\?) echo "Usage: waitfor [-f FILE] [-n] [-m] [-t n] user"
echo " -f FILE wait for the FILE to be created"
echo " -m be notified by mail"
echo " -n negate the desired test"
echo " -t N check every n secs (default $interval)"
exit 1;;
esac
done
# Make sure a user name was specified
if [ "$OPTIND" -gt "$#" -a -z "$waitfile" ] ; then
echo "Missing user name!" ; exit 2
fi
shiftcount=$(( $OPTIND - 1 ))
shift $shiftcount
user=$1
# Check for user logging on or for the file to appear
if [ -n $waitfile ] ; then
if [ $negate = TRUE ] ; then
while test -e $waitfile ; do
sleep $interval
done
else
until test -e $waitfile ; do
sleep $interval
done
fi
else
if [ $negate = TRUE ] ; then
while who | grep "^$user " > /dev/null ; do
sleep $interval
done
else
until who | grep "^$user " > /dev/null ; do
sleep $interval
done
fi
fi
# When we reach this point, the user has logged on
if [ $negate = TRUE -a -n $waitfile ] ; then
condition="no longer exists"
elif [ $negate = FALSE -a -n $waitfile ] ; then
condition="now exists"
fi
device="$( who | grep "^$user " | cut -c10-16 )"
if [ "$mailopt" = FALSE ] ; then
if [ -n "$waitfile" ] ; then
echo "File $waitfile $condition"
else
if [ $negate = TRUE ] ; then
echo "$user has logged out."
else
echo "$user has logged on to $device"
fi
fi
else
recipient=$(who am i | cut -cl-8)
if [ -n "$waitfile" ] ; then
echo "File $waitfile $condition" | mail $recipient
else
if [ $negate = TRUE ] ; then
echo "$user has logged out." | mail $recipient
else
echo "$user has logged on to $device" | mail $recipient
fi
fi
fi
You might also like to view...
The first step in a static analysis for intrusion detection is ________.
a) building a model of an application’s expected behavior b) monitoring an application’s system calls c) identifying vulnerabilities in an application d) developing a security plan
The ____ process can be performed at the firewall and make use of encryption to protect credentials transmitted from client to server (or client to firewall).
A. integrity B. confidentiality C. authentication D. nonrepudiation
Case-Based Critical Thinking QuestionsCase 3-1Linda doesn't know much about tweened animation, but she needs a crash course in it to prepare a multimedia presentation for her manager at the end of the week. Her colleague Sasha offers to help. Linda is looking at a series of frames. How can she confirm that a motion tween has been applied?
A. The frames have a light blue background. B. A solid line appears across the frames. C. A dashed line appears across the frames. D. both a. and b.
____________________ allows you to configure how processor resources are allocated to programs.
Fill in the blank(s) with the appropriate word(s).