Unexpected Token Error `;;'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unexpected Token Error `;;'
# 8  
Old 09-22-2010
That should be:
Code:
echo " Searching for the search String from ${archFilePattern} "

or
Code:
echo " Searching for the search String from \"${archFilePattern}\" "

# 9  
Old 09-22-2010
You might have fixed this one already.

Code:
   43          if [ "$1" != 0 ]|| [ "$1" != 0 ] ; then



---------- 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() {

# 10  
Old 09-22-2010
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

Code:
$ cat /config/app.properties.live.txt

Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log1"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log2"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log3"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log4"  
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log5"

AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log1"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log2"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log3"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log4"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log5"

EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log1"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log2"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log3"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log4"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log5"

FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log1"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log2"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log3"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log4"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log5"

The content of ArchiveFilePattern is nothing but the Zipped File & its Location

Code:
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log1*.log.gz"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log2*.log.gz"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log3*.log.gz"
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log4*.log.gz"  
Servicechoicepoint =  "/logs/Application/production/FSST/transaction/Servicechoicepoint_Log5*.log.gz"

AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log1*.log.gz"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log2*.log.gz"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log3*.log.gz"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log4*.log.gz"
AddAcctService ="/logs/Application/production/FSST/transaction/AddAcctService_Log5*.log.gz"

EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log1*.log.gz"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log2*.log.gz"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log3*.log.gz"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log4*.log.gz"
EquipmentService = "/logs/Application/production/FSST/transaction/EquipmentService_Log5*.log.gz"

FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log1*.log.gz"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log2*.log.gz"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log3*.log.gz"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log4*.log.gz"
FSSTError ="/logs/Application/production/FSST/transaction/FSSTError_Log5*.log.gz"

This is the Error Message .

Code:
./XMLsearch.sh -l Servicechoicepoint 

**********************************************************************
 Searching for the  Servicechoicepoint  XML in Request
**********************************************************************

./XMLsearch.sh: line 101: syntax error: unexpected end of file

Content of String File

Code:
$ cat stringFile.txt
<m:messageId>976625489</m:messageId>
<m:messageId>114972513</m:messageId>
<m:messageId>45287967</m:messageId>


Last edited by raghunsi; 09-22-2010 at 01:12 PM..
# 11  
Old 09-22-2010
Code:
.............................................


Last edited by john1212; 09-22-2010 at 02:14 PM..
# 12  
Old 09-22-2010
Line 61 and 69 need a }, not line 101 imo....
# 13  
Old 09-22-2010
I agree with Scrutinizer.

Also:

Syntax of the functions
Lines 54 and 62 need to be the same syntax as line 33.

Orphan code
Lines 42-46 don't belong in any of the functions.

Functions not called
Apart from "usage" I can't see calls to the other two functions.

Function names and variable names the same.
FilePattern and $FilePattern
myString and $myString

Dubious inward redirect (willl not work)
83 done < "${myString}"
94 done < "${myString}"
# 14  
Old 09-23-2010
Hi all,

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.

Code:
ls -ltr /logs/Application/production/FSST/transaction/ | grep -i ServicebyName

-rwx-r--r--  --------------------------- ServicebyName_Log1
-rwx-r--r--  --------------------------- ServicebyName_Log2
-rwx-r--r--  --------------------------- ServicebyName_Log3
-rwx-r--r--  --------------------------- ServicebyName_Log4
-rwx-r--r--  --------------------------- ServicebyName_Log5

When i run the script, it should start searching the STRING provided in stringFile.txt
from the LOG FILE Instances irrespectively in the log DIR .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Syntax error near unexpected token `('

detect_mouse_mvt.sh /home/andy/bin/detect_mouse_mvt.sh: line 4: syntax error near unexpected token `(' /home/andy/bin/detect_mouse_mvt.sh: line 4: `fh = file('/dev/input/mice')' #!/bin/bash # # fh = file('/dev/input/mice') while True: fh.read(3) print 'Mouse... (15 Replies)
Discussion started by: drew77
15 Replies

2. UNIX for Beginners Questions & Answers

Syntax error near unexpected token 'do'

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)
Discussion started by: gillesi
3 Replies

3. Shell Programming and Scripting

Syntax error near unexpected token `else'

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)
Discussion started by: masubram
14 Replies

4. Shell Programming and Scripting

Syntax error near unexpected token `|'

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)
Discussion started by: Meacham12
7 Replies

5. Shell Programming and Scripting

Syntax error near unexpected token `else'

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)
Discussion started by: Aryan12345
6 Replies

6. Shell Programming and Scripting

Syntax error near unexpected token `('

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)
Discussion started by: iiiiiiiiiii
2 Replies

7. Shell Programming and Scripting

syntax error near unexpected token `='

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)
Discussion started by: jaango123
3 Replies

8. UNIX for Dummies Questions & Answers

Syntax error near unexpected token

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)
Discussion started by: engr.jay
6 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `('

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)
Discussion started by: raghunsi
7 Replies

10. Shell Programming and Scripting

sh syntax error unexpected token done

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)
Discussion started by: NullPointer
5 Replies
Login or Register to Ask a Question