Sample CLI Script File - Create a New User

This following example demonstrates how a script can be used to create a sp user model.
You can execute shell scripts that incorporate CLI commands from the bash prompt in the Windows platform simply as you execute the command from the shell command prompt on UNIX.
This following example demonstrates how a script can be used to create a
CA Spectrum
user model.
# # Check to see if CLIPATH is set. If it is not then we will have to create it. # # Setup a variable to point to the /install_area/vnmsh directory so we can # find the commands we need. # if [ -z "$CLIPATH" ] then CLIPATH=/usr/data/spectrum/7.0/vnmsh export CLIPATH fi # # Test to make sure the CLIPATH points to a valid directory # if [ ! -d $CLIPATH ] then echo "ERROR: could not find $CLIPATH" echo "Please find the correct path to the vnmsh directory and set" echo "the CLIPATH environment variable to it." exit 0 fi # # Now check to see how many command line arguments there are. If there are # none, then echo a usage message. If there is one, that is all we really # need to create a new user... If there is a second argument then we can # set the Community_String at the same time. # # This setup is only for creating a user on the local system or what the # .vnmshrc file points to for the vnm_hostname. A third field could be # added that accepts the vnm_hostname to connect to. # # Optionally, the getopts shell command can be used to parse "switches" to # the script: -n for name, -c for community string and -v for vnm_hostname. # # (NOTE: getopts should be located in /usr/bin/getopts if the script is # done in bourne shell (sh). k-shell has a built in getopts function) # if [ $# -eq 0 ] then echo "Usage: $0 username [Community_String]" exit 1 elif [ $# -eq 1 ] then command="attr=0x1006e,val=$1" flag=0 elif [ $# -eq 2 ] then command="attr=0x1006e,val=$1 attr=0x1007a,val=$2" flag=1 fi # # Okay, we should be all set now to go ahead and create the new user. # The first thing we have to do is connect. # $CLIPATH/connect # # Now let's check the exit status of the connection to see if we got in... # if [ $? -ne 0 ] then echo "ERROR: could not connect to <ss>. $0 exiting" exit 0 fi # # Okay if we made it this far then we have a connection. Let's try the # create command. # $CLIPATH/create model mth=0x10004 $command # # Now we check the exit status again and see if we actually created a model. # if [ $? -ne 0 ] then echo "ERROR: could not create a new user. $0 exiting" exit 0 else echo -n "New user $1 created" if [ $flag -eq 1 ] then echo " Community_String was set to $2" fi echo "Successfully created new model... exiting." fi $CLIPATH/disconnect exit 1