Re: Using ":" as argument
From: mcgarble (marcbachman_at_sbcglobal.net)
Date: 05/11/05
- Next message: Chris F.A. Johnson: "Re: eval command"
- Previous message: Ralph Zajac: "Re: loop"
- In reply to: mcgarble: "Using ":" as argument"
- Next in thread: Chris F.A. Johnson: "Re: Using ":" as argument"
- Reply: Chris F.A. Johnson: "Re: Using ":" as argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Chris F.A. Johnson: "Re: eval command"
- Previous message: Ralph Zajac: "Re: loop"
- In reply to: mcgarble: "Using ":" as argument"
- Next in thread: Chris F.A. Johnson: "Re: Using ":" as argument"
- Reply: Chris F.A. Johnson: "Re: Using ":" as argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|