#!/usr/local/bin/tcsh  -f
#  kesu config  psname
if ( $#argv != 2 ) then
	echo "Usage: kesu configFile processname"
	exit 1
endif
#    set ps command( ps -efl  or ps aux  depending on the system)

set ps=`myps`
if( "x$ps" == "x" ) then
    echo myps should be modified
    exit 1
endif
#  alias gawk /usr/local/bin/gawk


if( "$ps[2]" == "aux" ) then
   set procn=`$ps | grep $USER | grep $2 | gawk 'index($0, "grep")==0 && index($0,"tcsh")==0 && index($0,"rsh")==0 {print $2}' `
else
   set procn=`$ps | grep $USER | grep $2 | gawk 'index($0, "grep")==0 && index($0,"tcsh")==0 && index($0,"rsh")==0 {print $4}' `
endif

#     choose oldest proces number


@  old = $$
foreach f($procn)
    if( $f < $old ) then
	@ old = $f
    endif
end

kill -9 $old








