Re: Using ":" as argument

From: mcgarble (marcbachman_at_sbcglobal.net)
Date: 05/11/05


Date: 10 May 2005 20:01:07 -0700

I have two scripts, one 180+ lines, the other 520+ lines. Because the
shorter one has a syntax error, I'll ask about it first. The error
message is:
./prog4.sh: line 190: syntax error near unexpected token `fi'
./prog4.sh: line 190: ` fi .
The following lines are the portion of the script that contain the
syntax error, I believe:
while getopts :roe options
do
case $options in
r) optflag=1 # this flag is set to 1 if options are present
ordflag=1 # this flag is set to 1 to call reverse order function
;;
o) optflag=1
sumflag=2 # This is the flag that is set to call the sumeven()
;;

e) optflag=1
sumflag=3 # This is the flag that is set to call the sumodd()
;;
esac
if [ $OPTIND -lt 2 ]
then printf "You must enter two integers. Rerun script "
fi
if [ $OPTIND -eq 2 ]
then
if [ $1 -ge 0 -a $1 -le 1000 ]
then
if [ $2 -ge 0 -a $2 -le 1000 ]
then printf " The numbers between $xvalue and $yvalue are:"
ascordesc #Function that prints number range ascending or desc
else
printf "You must enter two integers. Rerun script"
exit 1
fi
fi
fi
if [ $OPTIND -ge 3 ]#if options are present
if [ $optflag -eq 1 -a $ordflag -eq 0 ]
then
if [ $sumflag -eq 2 ]
then
sumeven #function to sum even numbers in range
elif [ $sumflag -eq 3 ]
then
sumodd #function to sum odd numbers in range
fi
fi
if [ $optflag -eq 1 -a $ordflag -eq 1 ]
then revorder # function that swaps variable values
ascordesc #function that prints numbers in range
fi
fi
done
If there is a way that I can improve my debugging skills other than
experience and intuition, I'm ready
Best Regards
McGearble



Relevant Pages

  • Re: Also on automatic semi-colon insertion ...
    ... the source code as a /Program/ if it encounters a syntax error. ... Obviously they don't say how the report is displayed. ... We are talking about a programming language here; ... However, HTML SCRIPT elements are ...
    (comp.lang.javascript)
  • Re: changing existing local user flag "never expires"
    ... set the flag "password never expires". ... A non-zero result means that the flag is ... which means that the script results in the flag not being ... If (lngFlags And ADS_UF_DONT_EXPIRE_PASSWD) = 0 Then ...
    (microsoft.public.scripting.vbscript)
  • Go to related records then find a subset
    ... my deepest condolences for what it is happening today in London. ... Find script step that includes all the desired parameters + the flag ... showing the records, I need to reset the flag field, so that it is ...
    (comp.databases.filemaker)
  • Re: I need to generate list of all SMTP address.
    ... For Each Item in strProxyAddress ... In regards to JamesTech's script, ... syntax error, "exportmail.vbsMS VBScript compilation error: ...
    (microsoft.public.exchange.admin)
  • Re: VBscript to set the inherit permissions in registry
    ... propogate to this object" on a workstation from a script. ... Dim objUser, objNtSecurityDescriptor, intNtSecurityDescriptorControl ... ' Save control settings in the security descriptor object. ... As with all flag settings, you "And" the property with the appropriate bit ...
    (microsoft.public.scripting.vbscript)