Unexpected Token Error `;;'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unexpected Token Error `;;'
# 1  
Old 09-22-2010
Unexpected Token Error `;;'

Hello all,

Im having an Issue with my script for switch statement , can someone let me know where do i need to correct it.

Code:
7  ##*******************************************************************************************************
     8  ##  **********  FUNCTION USAGE  ***********
     9  ##*******************************************************************************************************
    10  ##
    11
    12  # Script name without path
    13
    14  BASENAME=${0##*/}
    15
    16  #Default Config & Log Path
    17
    18  LOCATION=/home/63623AD
    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 DIR.
    39                   <OPTION>
    40                    <-L | -l>    = Searching from the LIVE LOGS.
    41                   <-A | -a>    = Searching from the ARCHIVE LOGS.
    42
    43          if [ "$1" != 0 ]|| [ "$1" != 0 ] then
    44          echo
    45          echo "  Check USAGE for correct Parameters  "
    46          fi
    47          exit 1
    48          }
    49          echo
    50          echo "**********************************************************************"
    51          echo " Searching for the  ${2} XML in Request "
    52          echo "**********************************************************************"
    53          echo
    54  # Check the  parameters
    55  #
    56  [ $# != 2 ] && usage
    57
    58  #Validate the Service Name from
    59  #
    60
    61  function FilePattern (){
    62  # Checking for the existence of Pattern File in the LOG DIR
    63
    64  fgrep "$2" ${FilePattern} > /dev/null || {
    65  echo  Service NOT Available
    66  exit 1
    67  }
    68
    69  function myString() {
    70  #Checking for the existence of the String in String File
    71
    72  fregrep ${mLine}  ${myString} > /dev/null || {
    73  echo String NOT found
    74  exit 1
    75  }
    76
    77  # Check the input parameters
    78  #
    79     case $1 in
    80
    81           -L | -l)
    82              myString="${LOCATION}/config/stringFile.txt"
    83              echo " Searching for the search String from "${liveFilePattern}" "
    84              while read mLine
    85              do
    86              egrep -i "${mLine}" "${liveFilePattern}"
    87              echo "++++++++++++++++++++++++++++++++++++++++++"
    88              echo "Searching for the line :----- $mLine from Live  LOGS"
    89              echo "++++++++++++++++++++++++++++++++++++++++++"
    90              done < "${myString}"
    91
    92          ;;
    93           -A | -a)
    94              echo " Searching for the search String from "${archFilePattern}"
    95              while read mLine
    96              do
    97              gzegrep -i "${mLine}" "${archFilePattern}"
    98              echo "++++++++++++++++++++++++++++++++++++++++++"
    99              echo "Searching for the line :----- $mLine from Archive LOGS"
   100              echo "++++++++++++++++++++++++++++++++++++++++++"
   101              done < "${myString}"
   102          ;;
   103           *)
   104                  usage
   105                  echo " Please check for correct Parameter from the Usage "
   106          ;;
   107      esac

The Error is

Code:
./XMLsearch.sh getservicebyname
./XMLsearch.sh: line 102: syntax error near unexpected token `;;'
./XMLsearch.sh: line 102: `        ;;'

# 2  
Old 09-22-2010
Remove ;; from last case.
Code:
*)
   104                  usage
   105                  echo " Please check for correct Parameter from the Usage "
   106          ;;
   107      esac

# 3  
Old 09-22-2010
I removed ;; from the case , but still seeing the same.

Code:
  ;;
         *)
                usage
                echo " Please check for correct Parameter from the Usage "
    esac



~
"XMLsearch.sh" 109 lines, 3041 characters
$ ./XMLsearch.sh servicebyname
./XMLsearch.sh: line 102: syntax error near unexpected token `;;'
./XMLsearch.sh: line 102: `        ;;'

# 4  
Old 09-22-2010
I think this is your problem:
Code:
echo " Searching for the search String from "${archFilePattern}"

remove the middle double quote...
# 5  
Old 09-22-2010
And we are missing some echo statements and quotes here:

Code:
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.

# 6  
Old 09-22-2010
Cleared the issue what methyl has asked .

But getting this error NOW

Code:
$ ./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.

Code:
 ./XMLsearch.sh -L SERVICEBYNAME
**********************************************************************
 Searching for the  SERVICEBYNAME XML in Request
**********************************************************************

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

# 7  
Old 09-22-2010
Code:
echo " Searching for the search String from "${archFilePattern}" "

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