-2

i have

 syntax error near unexpected token `elif'
`elif [[$# -gt 31]]

when i execute following script (its part from script by "Fred Weinhaus" for text-cleaner) by python 3

if [ $# -eq 0 ]     then    # help information
    echo ""
    usage2
    exit 0 elif [ $# -gt 31 ]               then    errMsg "--- TOO MANY ARGUMENTS WERE PROVIDED ---" else  while [ $# -gt 0 ]      do          # get parameter values          case "$1" in
          -h|-help)    # help information
                       echo ""
                       usage2
                       exit 0
                       ;;

how i solve this problem?

melpomene
  • 84,125
  • 8
  • 85
  • 148
Youssri Abo Elseod
  • 671
  • 1
  • 9
  • 23

1 Answers1

0

Your script has many mistakes. My fix may not be correct. Define "usage2".

#!/bin/bash
if [ $# -eq 0 ]; then    # help information
    echo ""
    #usage2
    exit 0
elif [ $# -gt 31 ]; then
    errMsg "--- TOO MANY ARGUMENTS WERE PROVIDED ---"
else while [ $# -gt 0 ]; do # get parameter values
    case "$1" in
    -h|-help) # help information
        echo ""
        #usage2
        exit 0
        ;;                                                                                                         
    esac
    done
fi

There are no errors in lines no 201 and 206. Try this code.

#!/bin/bash
usage2(){
    # dummy
    :
}

if [[ $# -eq 0 ]]
then
    echo ""
    usage2
    exit 0
elif [[ $# -gt 31 ]]
then
    errMsg "--- TOO MANY ARGUMENTS WERE PROVIDED ---"
else
    while [[ $# -gt 0 ]]
    do  
        :
    done                                  
fi
Yuji
  • 525
  • 2
  • 8