# a simple way of sending a message to another user ( workstation )

if ( ! $?ALERTER && -f /user/$user/.alerter ) then
    set ALERTER = `cat /user/$user/.alerter`
endif
if ( ! $?ALERTER ) then
    set ALERTER = /usr/local/bin/alert
endif

if ( $#argv < 1 ) then
    echo "usage : $0 host message ..."
else
    set noglob
    set host=$1
    set name = `grep $user /etc/passwd|awk -F: '{split($5,n," ");print n[1]}'`
    shift
    if ( $#argv == 0 ) then
	echo -n 'message : '
	cat - >! /tmp/tell$$
    else
	echo $* >! /tmp/tell$$
    endif
    setenv DISPLAY ${host}:0
    cat /tmp/tell$$ | $ALERTER -D font=6x13p button="OK, $name" >& /dev/null
    if ( $status ) then
	rsh $host -n '( set noglob; '$0' '$host' '$message' )'
    endif
endif
