|
|
This appendix contains a number of complete sample flow-through applications using the Script language.
This flow-through application lists the Services that each subscriber currently owns. This example can be expanded to include all attributes of the Service including its components or could be expanded to list the Services sorted within each subscriber (using the standard UNIX sort command).
#!/bin/ksh
#Lists the Services owned by customers matching the given search
#criterion.
#Syntax: listSO "CustomerCriterion"
# where CustomerCriterion is the criterion specifying the
# customer (s) passed in quotes.
# Note: passing an empty string will return services with empty
# customer fields and not the services for all customers. Use *
# to retrieve the services for all customers.
set -A SOClasses RAsvServiceObject RFsvServiceObject RFixServiceObject
set -A SOType ATM FR IWK
NUMSOC=${#SOClasses[*]}
echo "Customer Type SO ID Endpoint A EndpointB"
echo
"===================================================================="
. $CCP_BIN/npsinit
#---- Inspect each SO Class ----
INDEX=0
while ( ( $INDEX < $NUMSOC ) ) ; do
nps selectmany $ {SOClasses [$INDEX]} vpn="$1" SOLIST NUMSO
ITEM=1
while ( ( <= $NUMSO ) ) ; do
nps readitem $SOLIST $ITEM SOID SOATTS
nps retrieve SOATTS a_tp A_ENDPOINT
nsp retrieve SOATTS z_tp Z_ENDPOINT
nps retrieve SOATTS vpn VPN
if [X"$VPN" = X"" ]
then
VPN="=="
fi
printf "%-18s %-5s %-23s &-20s %-20s\n" \
"VPN" ${SOType [$INDEX]} $SOID $A_ENDPOINT $Z_ENDPOINT
( (ITEM=$ITEM+1) )
done
( ( INDEX=$INDEX+1) )
done
nps stop
Sample output, with listSO "Sy*":
Customer Type SO ID Endpoint A Endpoint B
=========================================================================================
Syndesis ATM RAsvSericeObject:2038 Gomer.Goober/1.1
Node5/DS3-S1-C6-D1
Syndesis IWK RFixServiceObject:1009 L9002/FT1-3-1-1 Gomer./1.1
Sample output, with listSO "*":
Customer Type SO ID Endpoint A Endpoint B
=========================================================================================
Syndesis ATM RAsvServiceObject:2038 Gomer.Goober/1.1 Node5/DS3-S1-C6-D1
-- ATM RAsvServiceObject:2035 Gomer./1.1 Gomer.Goober/1.1
-- ATM RAsvServiceObject:2036 Gomer./1.1 Gomer.Goober/1.1
JOE Customer Inc ATM RAsvServiceObject:2037 Gomer.Goober/1.1 Node5/DS3-S1-C6-D1
Syndesis IWK RFixServiceObject:1009 L9002/FT1-3-1-1 Gomer./1.1
Acme IWK RFixServiceObject:1010 L9002/FT1-3-1-1 Gomer./1.1
This flow-through application deletes Transactions that are older than a month. This type of application is useful to administrators who have to deal with repetitive tasks.
#!/bin/ksh #Deletes transactions older than a month #Syntax: deltrans . $CCP_BIN/npsinit trap "nps error" ERR nps selectmany CR number=* TRLIST NUMTRS ITEM=1 while [ $ITEM -le $NUMTRS ] do nps readitem $TRLIST $ITEM TRID TRATTS nps read $TRID TRATTS nps retrieve TRATTS submissiondate TR_DATE_STR nps retrieve TRATTS number TR_NUM
# Convert the Transaction date to YYYYMMDD format
TR_DATE='echo "TR_DATE_STR" \
| sed -e "s/JAN/01/g
s/FEB/02/g;
s/MAR/03/g;
s/APR/04/g;
s/MAY/05/g;
s/JUN/06/g;
s/JUL/07/g;
s/AUG/08/g;
s/SEP/09/g;
s/OCT/10/g;
s/NOV/11/g;
s/DEC/12/g;
s/-/ /g"
| awk `{print $1 $2 $3}''
# Get the current date as YYYYMMDD and decrement the MM digits
CURR_DATE='date +%Ym%d'
CUTOFF_DATE='expr $CURR_DATE - 100'
# Delete Transactions with earlier dates than the cutoff
if [ [ $TR_DATE -le $CUTOFF_DATE ] ]
then
echo "Deleting Transaction $TR_NUM from $TR_DATE_STR"
AVcr delete $TR_NUM VM
fi
( (ITEM=$ITEM+1) )
done
nps stop
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Posted: Thu Aug 3 16:20:43 PDT 2000
Copyright 1989-2000©Cisco Systems Inc.