Scripting geeks please advice how this script should parse the input parameter to File Name convention to search the strings. Enclosed is the basic view of the search architecture.
##*******************************************************************************************************
## ********** FUNCTION USAGE ***********
##*******************************************************************************************************
##
# Script name without path
BASENAME=${0##*/}
#Default Config & Log Path
LOCATION=/home/gt777888
#
#
#
#The INFILE is going to use during the SSH
liveFilePattern="${LOCATION}/config/app.properties.live.txt"
archFilePattern="${LOCATION}/config/app.properties.archive.txt"
#The Log Path for the File Pattern
LOG_DIR="/logs/prodcution/application/tranlogs"
#The String Search File
myString="${LOCATION}/config/stringFile.txt"
# Functional Usage
function usage() {
if [ $# ! = 0 ];
then
echo
echo "************************************************************"
echo " CHECK USAGE FOR CORRECT PARAMETERS "
echo "************************************************************"
echo
echo " USAGE: "
echo
echo " $BASENAME <OPTION> <SERVICE_NAME> "
echo
echo " <SERVICE_NAME> = Enter the vaild SERVICE_NAME that exists in 76S DIR.
<-L | -l> = Searching from the LIVE LOGS.
<-A | -a> = Searching from the ARCHIVE LOGS."
else
echo
echo "***********************************************************************************************"
echo " Searching for the ${2} XML in Request "
echo "***********************************************************************************************"
echo
fi
}
#Validate the Service Name from
#
function FilePattern (){
# Checking for the existence of Pattern File in the LOG DIR
if [ ! -f "${FilePattern}" -o ! -r "${FilePattern}" ]
then
echo "ERROR: Unable to find file: [${FilePattern}]."
logFNPatArray
[*]=(`cat "${FilePattern}"`)
for logFNpattern in "${logFNPatArray
[*]}"
do
ControLog=0
pathAndlogFile="${LOG_DIR}/${logFNpattern}"
ls -1 "${pathAndlogFile}"2>/dev/null
done
fi
}
function myString() {
#Checking for the existence of the String in String File
fregrep ${mLine} ${myString} > /dev/null || {
echo String NOT found
exit 1
}
}
# Check the input parameters
#
case $1 in
-L | -l)
for file in $logFNpattern
do
echo "searching for the search pattern in the file $logFNpattern"
while read mLine
do
egrep -i "${mLine}" "${pathAndlogFile}"
echo "Searching for the line :----- $mLine from Live LOGS"
done < "${myString}"
done
;;
-A | -a)
while read mLine
do
gzegrep -i "${mLine}" "${FilePattern}"
echo "Searching for the line :----- $mLine from Archive LOGS"
done < "${myString}"
;;
*)
usage
[ "$#" != "2" ] || usage
esac
exit
Out put of the script:
$ ./XMLsearch.sh -l queryserviceinfoservice
$ echo $?
0
$
My script is not extracting the log for the strings defined in $myStrings from the "queryserviceinfoservice" file instance . Resulting NULL.
Scripting Geeks, please help me out.:(
But similar to example , the log directory contains 180 X 5 Files [180= different Files, 5= Patterned whose suffix are *.log1, *.log2 , *.log3, *.log4, *.log5 .
Below is given eg:
XML_to_choicepoint = "${LOG_DIR}/XML_to_choicepoint_Log1"
XML_to_choicepoint = "${LOG_DIR}/XML_to_choicepoint_Log2"
XML_to_choicepoint = "${LOG_DIR}/XML_to_choicepoint_Log3"
XML_to_choicepoint = "${LOG_DIR}/XML_to_choicepoint_Log4"
XML_to_choicepoint = "${LOG_DIR}/XML_to_choicepoint_Log5"
ADDACCTNTSWS ="${LOG_DIR}/ADDACCTNTSWS_Log1"
ADDACCTNTSWS ="${LOG_DIR}/ADDACCTNTSWS_Log2"
ADDACCTNTSWS ="${LOG_DIR}/ADDACCTNTSWS_Log3"
ADDACCTNTSWS ="${LOG_DIR}/ADDACCTNTSWS_Log4"
ADDACCTNTSWS ="${LOG_DIR}/ADDACCTNTSWS_Log5"
APIEquipment = "${LOG_DIR}/APIEquipment_Log1"
APIEquipment = "${LOG_DIR}/APIEquipment_Log2"
APIEquipment = "${LOG_DIR}/APIEquipment_Log3"
APIEquipment = "${LOG_DIR}/APIEquipment_Log4"
APIEquipment = "${LOG_DIR}/APIEquipment_Log5"