I currently have a Unix program where I'm trying to correctly use a getopts while loop with a case command nested inside. Inside that getopts while loop is a case command and inside the case case is two options that both are until loops. Here is the current code:
while getopts ufn: user
do
case "$user"
in
u)
tty=$(who | grep "$user " | cut -d\ -f 2)
until who | grep "$user " > /dev/null
do
sleep 60
done
echo "$user has logged onto $tty";;
f)
until find | home/students/shaunkolkman/$user
do
test -d $user || test -f $user
sleep 20
done
echo "$user is a file or directory";;
esac
done
user=$1
Option u is a until loop that looks for someone to log on and show what tty that user is on. Option f is a until loop finding either a file or directory. The until loops work perfectly fine. Option n will be added later once I figure out this problem.
Here's a example snipppet with a description of what is going on.
./mon4 -f vex
The issue I'm facing is that the f from -f is being seen as the variable. Along with -f still being read as a option from getopts. I don't understand why vex isn't read as the variable.