Getopts: user has logged off part not working... help needed....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lacreme
    New Member
    • Aug 2007
    • 5

    Getopts: user has logged off part not working... help needed....

    I am trying to write a script with the getopts options. It does everything I want it to except tell me when the specified user has logged off. I am not sure if I set the option wrong or if it is the if untill loop. Here is only part of the script (bash shell).

    mailopt=FALSE
    interval=60
    logoff=FALSE
    # process command line options

    while getopts mtn: options
    do
    case "$options"
    in
    m) mailopt=TRUE;;
    t) interval=$OPTAR G;;
    n) logoff=TRUE;;

    if [ "$logoff" = TRUE ]
    then
    until who | grep -v "^$user" > /dev/null
    do
    sleep 60
    done
    echo "$user has logged off"
    fi

    #like I said this is only the part I think has the problem. I also tried....until who | grep "^$user" > /dev/null = FALSE
Working...