And we are missing some echo statements and quotes here:
38 echo "<SERVICE_NAME> = Enter the vaild SERVICE_NAME that exists in DIR.
39 <OPTION>
40 <-L | -l> = Searching from the LIVE LOGS.
41 <-A | -a> = Searching from the ARCHIVE LOGS.
$ ./XMLsearch.sh servicebyname
./XMLsearch.sh: line 46: syntax error near unexpected token `fi'
./XMLsearch.sh: line 46: ` fi'
---------- Post updated at 03:25 AM ---------- Previous update was at 03:16 AM ----------
Above error is cleared, but found something new.
./XMLsearch.sh -L SERVICEBYNAME
**********************************************************************
Searching for the SERVICEBYNAME XML in Request
**********************************************************************
./XMLsearch.sh: line 104: syntax error: unexpected end of file
---------- Post updated at 13:43 ---------- Previous update was at 13:09 ----------
Also there are two alternative syntaxes to start a function:
function identifier {list;}
identifier () {list;}
One of these conforms to the syntax rules and two do not:
33 usage() {
61 function FilePattern (){
69 function myString() {
Somewhere the script is not reading the input parameter & not searching the string in that file, rather its showing an error. Can anybody help me to figure out.
12 # Script name without path
13
14 BASENAME=${0##*/}
15
16 #Default Config & Log Path
17
18 LOCATION=/home/23456jg
19 #
20 #
21 #
22 #The INFILE is going to use during the SSH
23
24 liveFilePattern="${LOCATION}/config/app.properties.live.txt"
25 archFilePattern="${LOCATION}/config/app.properties.archive.txt"
26
27 #The String Search File
28
29 myString="${LOCATION}/config/stringFile.txt"
30
31 # Functional Usage
32
33 usage() {
34 echo
35 echo "USAGE"
36 echo " $BASENAME <OPTION> <SERVICE_NAME> "
37 echo
38 echo "<SERVICE_NAME> = Enter the vaild SERVICE_NAME that exists in 76S DIR.
39 <-L | -l> = Searching from the LIVE LOGS.
40 <-A | -a> = Searching from the ARCHIVE LOGS."
41 }
42 echo
43 echo "**********************************************************************"
44 echo " Searching for the ${2} XML in Request "
45 echo "**********************************************************************"
46 echo
47 # Check the parameters
48 #
49 [ "$#" != "2" ] && usage
50
51 #Validate the Service Name from
52 #
53
54 function FilePattern (){
55 # Checking for the existence of Pattern File in the LOG DIR
56
57 fgrep "$2" ${FilePattern} > /dev/null || {
58 echo Service NOT Available
59 exit 1
60 }
61
62 function myString() {
63 #Checking for the existence of the String in String File
64
65 fregrep ${mLine} ${myString} > /dev/null || {
66 echo String NOT found
67 exit 1
68 }
69
70 # Check the input parameters
71 #
72 case $1 in
73
74 -L | -l)
75 myString="${LOCATION}/config/stringFile.txt"
76 echo " Searching for the search String from \"${liveFilePattern}\" "
77 while read mLine
78 do
79 egrep -i "${mLine}" "${liveFilePattern}"
80 echo "++++++++++++++++++++++++++++++++++++++++++"
81 echo "Searching for the line :----- $mLine from Live LOGS"
82 echo "++++++++++++++++++++++++++++++++++++++++++"
83 done < "${myString}"
84
85 ;;
86 -A | -a)
87 echo " Searching for the search String from \"${archFilePattern}\" "
88 while read mLine
89 do
90 gzegrep -i "${mLine}" "${archFilePattern}"
91 echo "++++++++++++++++++++++++++++++++++++++++++"
92 echo "Searching for the line :----- $mLine from Archive LOGS"
93 echo "++++++++++++++++++++++++++++++++++++++++++"
94 done < "${myString}"
95 ;;
96 *)
97 usage
98 echo " Please check for correct Parameter from the Usage "
99 esac
100 exit
The content of LiveFilePattern is nothing but the File & Location
./XMLsearch.sh -l Servicechoicepoint
**********************************************************************
Searching for the Servicechoicepoint XML in Request
**********************************************************************
./XMLsearch.sh: line 101: syntax error: unexpected end of file
But from the above , i corrected few error. Script is running with string trying to search from the File Pattern file , but not from the File it supposed. Can anybody sort out this, where the script is pointing to.
Any help will be much appreciative
$ bash -x XMLsearch.sh -l dp_querysubscriberinfoservice
+ BASENAME=XMLsearch.sh
+ LOCATION=/home/232425jg
+ liveFilePattern=/home/232425jg/config/app.properties.live.txt
+ archFilePattern=/home/232425jg/config/app.properties.archive.txt
+ myString=/home/232425jg/config/stringFile.txt
+ echo
+ echo '**********************************************************************'
**********************************************************************
+ echo ' Searching for the ServicebyNameXML in Request '
Searching for the ServicebyNameXML in Request
+ echo '**********************************************************************'
**********************************************************************
+ echo
+ case $1 in
+ read mLine
+ egrep -i 414d51204450303141504420202020204c91dcdb2d7488c0 ''
egrep: can't open
+ echo 'Searching for the line :----- 414d51204450303141504420202020204c91dcdb2d7488c0 from Live LOGS'
Searching for the line :----- 414d51204450303141504420202020204c91dcdb2d7488c0 from Live LOGS
+ read mLine
+ exit
Can anyone able to correct above script, to redefine the search of the STRING from the Files , where Files Patterns resembles each other as given above.
For eg:
MSgID:8743287jjhs73498eojwe9834732h8302kdw8
The above string has to be searched from the input parameter "ServicebyName".
But in my log path i have five instance of these file as given below. When ever i provide these "ServicebyName" it should read & match from the FilePatternlist.txt file and should get me the result.