Trying to run a bash script and while some things work correctly, I get this message:
line 34: unexpected EOF while looking for matching `)'
Here's the code, I've marked the line in question (in the hypotenuse method):
#!/bin/bash
# Bash Script Calculator
# -----------------------------------------------------
#
#
#
# -----------------------------------------------------
a=$1
op="$2"
b=$3
if [ $# -lt 3 ]
then
echo "$0 num1 opr num2"
echo "Operators: +,-,x,/"
exit 1
fi
case "$op" in
+) echo $(( $a + $b ));;
-) echo $(( $a - $b ));;
x) echo $(( $a * $b ));;
/) echo $(( $a / $b ));;
hyp) hypotenuse;;
area) area;;
*) echo "Error: Not a listed operator"
echo "If using multiplication, use "x"";;
esac
hypotenuse()
{
hyp=$(bc -l << EOF #LINE 34
scale = 9
sqrt ( $1 * $1 + $3 * $3 )
EOF
)
echo "$hyp"
}
area()
{
area=$(echo "scale=2;3.14 * ($a * $a)" | bc)
echo "$area"
}
Am I missing something? I've spent a little time looking things up on Google and such, nothing seems to tell me otherwise.
Thanks for any help!