---------- Post updated at 13:43 ---------- Previous update was at 13:09 ----------
Code:
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.
Code:
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
Code:
$ 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:
Code:
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.
Hello all,
Please i have this command i used to zip different files in differents directory, but i have an error. Note that when i run the command in one directory it works fine.
/X5/WORK/BGH/INV/REG/pdf/SEND/BGH12523/1/*.fo
/X5/WORK/BGH/INV/REG/pdf/SEND/BGH24523/1/*.fo... (3 Replies)
Hello every one!!
I don't know where I am going wrong but I am finding it difficult to clear this error of syntax error near unexpected token `else'
I am writing a simple shell script to find a file in a directory and if found execute that else return an error to the log file
... (14 Replies)
Hi All;
I try to write a bash code and I am using command substitution. My code is like:
#!/bin/bash
IP="10.0.0.1 10.0.0.2"
PORT="22 80"
USERNAME="admin"
SCRIPT_HOST="adminHost"
HOME_DIR=/home/admin
SCRIPT_DIR=$HOME_DIR/scripts
script="sudo /my_remote_script.sh"
SSH="/usr/bin/ssh... (7 Replies)
Hi,
I am trying to read the session log through script. But it keeps showing me some error near. I have tried everything. Even tried converting the script using sed command to remove the hidden characters(\r).But nothing seems to be working.Below is the script :
#!/bin/bash
cd... (6 Replies)
What do I do here?
#!/bin/bash
payload=-1 AND 1=IF(21,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)#
hash=`echo -n $payload md5sum tr -d 'n' sed 'ss-sg' md5sum tr -d 'n' sed 'ss-sg'`
curl --data cs2=chronopay&cs1=$payload&cs3=$hash&transaction_type=rebill... (2 Replies)
Hi all,
This is a script which converts hex to bin. However am finding an error while executing
syntax error near unexpected token `='
`($hexfile, $binfile) = @ARGV;'
I am running using ./fil.pl <hexfile> <binfile>
###################################################
#
# this script... (3 Replies)
hi! just want to seek help on this error: syntax error near unexpected token 'do
this is my script
# !/bin/sh
#
for y in 27 25
do
exemmlmx -c "ZEEI;" -n XRT$y >> blah
done
what can be wrong? thanks! (6 Replies)
Guys ,
This is an output of my script errored out for "Syntax error near unexpected token `(' " Can someone tell me whats wrong with my script.
Below is my original script pasted.
#!/bin/bash
Script Creation Date 01/21/2010
Author baraghun
... (7 Replies)
I'm getting the following error:
line 21: syntax error near unexpected token `done`
line 21: `done`
and I haven't been able to figure out why.
Here is my code
#!/bin/sh
if ; then
echo 'Usage: rename getexp/replStr '
exit 0
fi
arg = $1
shift
while ; do (5 Replies)