#
# A script to change cabletron repeater port stati
#
# Tom Coppeto
# MIT Network Services
# 3 November 1991
#
# $Source: /afs/net.mit.edu/tools/src/crpw/RCS/crpw,v $
# $Author: tom $
# $Header: /afs/net.mit.edu/tools/src/crpw/RCS/crpw,v 1.1 91/04/23 10:59:34 tom Exp Locker: tom $
#
#!/bin/csh -f

set path      = (/usr/ucb /usr/bin /bin /mit/snmp/nyser/@sys)
set svar      = _private_enterprise_52.1.2.2.4.1.3
set varfile   = /mit/snmp/nyser/etc/snmp.variables

if($#argv != 3) then
	echo "Usage: cport <repeater> <board> <port>"
	exit 1
endif

if ( ! -r $varfile ) then
        echo -n "attaching snmp... "
        /bin/athena/attach snmp
        if (! -r $varfile) then
                echo "Unable to read SNMP variables file."
                exit 1
        endif
endif


set addr   = $argv[1]
set board  = $argv[2]
set port   = $argv[3]


echo -n "community: "
stty -echo
set comm = ($<)
stty echo
echo ""

set descr = `snmpquery -c $comm $addr $svar.$board.$port`
if($status) then
	echo "unable to contact agent (check community)"
	exit 1
endif


set pstatus = `snmpquery -c $comm $addr $svar.$board.$port | awk '{FS="\t"; print $2}'`
echo -n "status  [$pstatus]: "
set pstatus = ($<)
if($pstatus != "") then
	snmpset -c $comm $addr $svar.$board.$port $pstatus
	if($status) then
		echo "errors in setting variable... exitting"
		exit 1
	endif
endif
