#! /bin/sh
# The SPIMS software is covered by a license. The use of the software
# represents acceptance of the terms and conditions in the license.
# ******************************************************************
# Copyright (c) 1989, Swedish Institute of Computer Science
# $1 protocol
# $2 optional host
if [ $# = "0" ]; then
    echo "Usage: $0 host protocols"
    exit 1
fi
HOST=$1
shift
if [ $HOST = `hostname` ]; then
for p in $*; do
#    if [ -f /usr/local/bin/sps ]; then
#        eval `/usr/local/bin/sps | \
#            awk  '\
#                BEGIN {printf "kill -9 "} \
#                $4 ~ /\/demon/ {if (substr($4,1,length($4)-6) == proto) \
#                            printf "%d ", $3} \
#                END { printf "\n"} \
#            '  /dev/null proto=$p - `
#    else
        eval `ps -x | \
            awk  '\
                BEGIN {printf "kill -9 "} \
                $5 ~ /\/demon/ {if (substr($5,1,length($5)-6) == proto) \
                            printf "%d ", $1} \
                END { printf "\n"} \
            '  /dev/null proto=$p - `
#    fi
done
else
    rsh $HOST -n "(cd \$SPIMSDIR; killdemon $HOST $*;)" 
fi    
