Ref: 99980056
Title: Adding New Commands on the NCS/1
Date: 12/1/85

Copyright 3Com Corporation, 1991.  All rights reserved.

The NCS/1 is a workstation using the 4.2 BSD UNIX operating
system.  Therefore, a network manager with some knowledge about
the UNIX operating system can tailor the NCS/1 to perform
specific tasks by writing UNIX shell scripts on the NCS/1.
Bourne sheel or C-shell scripts can be written and installed in
the NCS/1.  For a more detailed description of these shell
scripts, refer to the UNIX Programmer's Manual.

The following examples illustrate the use of shell scripts in the
NCS/1.

EXAMPLE 1: To ensure the security of the network, the global
password should be changed frequently.  If there are several
macros in the system, changing the global password for each macro
can be a tedious and time consuming task for a network manager.
This C-shell script can simultaneously change all the macros in
the system to a new global password.

#! /bin/csh
#
#  NAME
#       changepwd
#
#  PURPOSE
#       Change the global password and all the references to it
#       in all the macros files.
#  SYNOPSIS
#       changepwd <old_passwd> <new_passwd>
#
#  BUG
#       It replaces all occurrences of <old_passwd> strings even
#       though it could be a command, i.e., don't choose a
#       password that is also a legal command that has no
#       arguments.
#
#
onintr cleanup
#
if ( $#argv < 2 ) then
        echo "Usage: changepwd <old_passwd> <new_passwd>"
        exit -1
endif
#
setd gpw = \"$argv[2]\"
#
foreach i ( 'show mac')
   echo modifying $i
   show mac -E $i | sed -e 's/^'$argv[1]'$/'$argv[2]'/' > /tmp/
   mac.$$
   define $i < /tmp/mac.$$
end
#
cleanup:
   rm -f /tmp/mac/$$


EXAMPLE 2:  This C-shell script plots eight current events
occurring on a network in an ASCII form and then submits these
plots to the line printer.

# ! bin/csh -f
#
#  NAME
#       make_plots
#
#  PURPOSE
#       Plotting the connections, disconnections, total
#       connections, connection failures, connections queued,
#       disconnections queued, Ethernet utilization, and boot
#       requested events.
#
#  SYNOPSIS
#       make_plots <month> <date>
#
#
foreach   i  ( CD DC TOTALCD CF CQ DQ EU BR)
        echo -n "plot $i :"
        plot -a $i $argv[1] $argv[2] | lpr -Plw
        #if there is a laser printer connected to the NCS/1
        echo "done"
end
#

The above shell scripts should be created under the "/usr/ncs/
local" directory.  To execute these shell scripts after they have
been installed, enter the following command:

        chmod+x <shell script name>


