#!/bin/csh
# Improved version of "users" command, 'cos "users" only spots remote
# connections!

set q = `who | sort | awk '{print $1}' | uniq`

foreach w ( $q[*] )

  set z = "`who | grep -v "dtremote" | awk '/'$w'/{print $6}'`"
  @ z = `expr "$z" : ".*(.*"`
  if ( $z > 0 ) then
    set z = '*'
  else
    set z = ' '
  endif

  if ( $#argv == 0 ) then
    echo -n "$w $z "
  endif

  if ( $#argv == 1 && $1 == "-1" ) then
    echo "	$w $z "
  endif

end
