Below is my complete code, what i want is to take Trunk Group in the input and pass it to nawk (BEGIN). Below mentioned code is not giving any output.
Also see code below which gives perfect output, if i give TG
simple value like TG=700.
KarachiOMP adnan> vi tgcmp602
#!/bin/sh
#
# Variable TG has to be set according to the trkg desired.
#
# Also the rop file has to be updated according with the date
# ander analysis.
# ie:
# /omp-data/logs/5etr/yymmdd.APX
#
##############################################
# Get the date stamp you want
##############################################
CurrentDate=`date +%y%m%d`
echo "Enter Search Date [$CurrentDate]:"
read SearchDate
if [ "$SearchDate" = "" ]
then
SearchDate=${CurrentDate}
fi
echo "Enter TRUNK GROUP:"
read TGR
cat /omp-data/logs/5etr/$SearchDate.APX | nawk -F"|" -v P=$TGR '
BEGIN {
TG=P;
printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n");
}
/TRFTR TGCOMP/ {
getline; getline;
split($2,a,"-");
date=a[2]a[3];
getline; getline; getline;
interval=$2; split($3,a,":"); start=a[1]; split($4,a,":"); end=a[1];
}
/TGN ISEIZE/ {
getline;
tgn=$1; iseize=$2; isattmp=$5; ians=$6;
}
/TGN OATTMPT/ {
getline;
oattmpt=$2; ovfl=$4; oseize=$5; osattmp=$7;
}
/TGN OANS/ {
getline;
oans=$2; totusg=$3;
}
/TGN BWOUTU/ {
getline;
oosmtce=$4;
oos=$5;
}
/TGN DBLSZR/ {
getline;
dblszr=$2;
}
/TGN SBBSY/ {
getline;
ntwcong=$4;
}
/TGN TRKNAV/ {
if (tgn==TG) {
printf("%s %2d %2d %2d %4d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n", date, interval, start, end, tgn, iseize, isattmp, ians, oat
printf("%s %2d %2d %2d %4d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n", date, interval, start, end, tgn, iseize, isattmp, ians, oat
tmpt, ovfl, oseize, osattmp, oans, totusg, oosmtce, oos, dblszr, ntwcong);
}
}
END {
} '
exit
:q!
Code below which gives perfect output, if i give TG
simple value like TG=700.
KarachiOMP adnan> vi tgcmp602
#!/bin/sh
#
# Variable TG has to be set according to the trkg desired.
#
# Also the rop file has to be updated according with the date
# ander analysis.
# ie:
# /omp-data/logs/5etr/yymmdd.APX
#
##############################################
# Get the date stamp you want
##############################################
CurrentDate=`date +%y%m%d`
echo "Enter Search Date [$CurrentDate]:"
read SearchDate
if [ "$SearchDate" = "" ]
then
SearchDate=${CurrentDate}
fi
#echo "Enter TRUNK GROUP:"
#read TGR
cat /omp-data/logs/5etr/$SearchDate.APX | nawk '
BEGIN {
TG=700;
printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n");
}
/TRFTR TGCOMP/ {
getline; getline;
split($2,a,"-");
date=a[2]a[3];
getline; getline; getline;
interval=$2; split($3,a,":"); start=a[1]; split($4,a,":"); end=a[1];
}
/TGN ISEIZE/ {
getline;
tgn=$1; iseize=$2; isattmp=$5; ians=$6;
}
/TGN OATTMPT/ {
getline;
oattmpt=$2; ovfl=$4; oseize=$5; osattmp=$7;
}
/TGN OANS/ {
getline;
oans=$2; totusg=$3;
}
/TGN BWOUTU/ {
getline;
oosmtce=$4;
oos=$5;
}
/TGN DBLSZR/ {
getline;
dblszr=$2;
}
/TGN SBBSY/ {
getline;
ntwcong=$4;
}
/TGN TRKNAV/ {
if (tgn==TG) {
printf("%s %2d %2d %2d %4d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n", date, interval, start, end, tgn, iseize, isattmp, ians, oat
printf("%s %2d %2d %2d %4d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n", date, interval, start, end, tgn, iseize, isattmp, ians, oat
tmpt, ovfl, oseize, osattmp, oans, totusg, oosmtce, oos, dblszr, ntwcong);
}
}
END {
} '
exit
:q!
Please Help...
Regards,
Waqas Ahmed