Hi Neil, determined aren't you (thanks)
Hope this isn't too much info for you. At least you can get a better feel for what I'm TRYING to do ;-)
BTW IT IS actually slightly better formatted than you can see here.
This is what I get from your 2nd command
who -q | grep -v "#" | xargs finger -s | sort -u
aaaaaaaa aaaaaaaaa bbbbbbbbbb pts/4 2 Wed 13:07 GOOSE
aisha Aisha Xxxxxx pts/0 Wed 13:06 GOOSE
Login Name TTY Idle When Where
robin Robin Xxxxxxx *pts/3 2 Wed 13:07 GOOSE
root Super-User console Wed 13:09 :0
root Super-User pts/2 Wed 13:09 :0.0
sendmesg () {
IFS="
"
PS3="${REVERSE}Select the user you want to send a message to:${OFF} "
echo "\n${BOLD}Note${OFF}: The 2nd field shows the terminal, if preceded by an asterisk \"*\", the user may not be accepting messages\n"
echo "Users Currently logged in are: \n"
select USER in `who |awk '{print $1}'|sort|uniq|xargs finger -s|tail +2| sed -e 's/-/ /'|awk '{printf "%-8s %-8s %10s %-10s\n", $1,$4,$2,$3}'` Exit
do
TTY=`echo $USER|cut -c10-17`
REJECT=`echo $USER|cut -c10`
USER=`echo $USER|cut -c1-8`
case $USER in
Exit) PS3="${REVERSE}Your current directory is $(pwd), Enter your menu choice:${OFF} "
return;;
*) read MESG?"Please enter a short message: ";
if eval write $USER "$TTY" <<-END
$MESG
END
then
echo "Your message was successfully sent\n"
else
echo "Your message could not be delivered, the user may not be accepting messages. Sorry\n"
fi
PS3="${REVERSE}Your current directory is $(pwd), Enter your menu choice:${OFF} "
return;;
esac
done
}
This is the output, nt exactly what I want becasue I can't actually see how to set up $REJECT and do anything with it in the select list, obviously I can do something with it later. I would have actually liked to have it as a seperate column but the way I'm awk-printing it alters the column
Note: The 2nd field shows the terminal, if preceded by an asterisk "*", the user may not be accepting messages
Users Currently logged in are:
1) aaaaaaaa pts/4 aaaaaaaaa bbbbbbbbbb
2) aisha pts/0 Aisha Xxxxxx
3) robin *pts/3 Robin Xxxxxxx
4) root console Super User
5) root pts/2 Super User
6) Exit
Select the user you want to send a message to: