> 5 ")syntax error: operand expected (error token is " error

im kinda new to shell scripting so i need some help

i try to run this script and get the error code
> 5 ")syntax error: operand expected (error token is "

the code for the script is

#!/bin/sh
#
# script to see if the given value is correct
#
# Define errors
ER_AF=86 # Var is higher than five
ER_BO=87 # Var is below one
# Constants
a=5
b=1
# Execute sio and
# give var the output value of sio
var="$(/disk/sio -p3 -b57600 -R)"
echo $var
echo
# Test if var is above 5
if (( "$var" > "$a" ));
 then 
 echo "test failed" # Var is higher than 5
 exit $ER_AF
else
# Test if var is below 1
 if (( "$var" < "$b" ));
  then
  echo "test failed" # var is below 1
  exit $ER_BO
 else
  echo "test succes" # var is between 1 & 5
 fi
fi

sio gives a numerical value as reply
dont know whats wrong :wall:

What is the output from this bit of the script?

The error suggests that this is something to do with $var not being an integer number.

it's just a decimal value, like 1, 2, 3 and so on
sio reads a value from a com-port and sends it to the terminal

Can we see exactly what the program produces? The "sed" is to make all characters visible

var="$(/disk/sio -p3 -b57600 -R)"
echo "$var" | sed -n l

By the way, what Operating System and version do you have? This should dictate what type of Shell is /bin/sh .

I actually think that $var is empty, but I don't the same Shell as you in order to generate the exact error message.

found the problem...

# Test if var is above 5
if (( "$var" > "$a" ));
 then 
 echo "test failed" # Var is higher than 5
 exit $ER_AF

has to be

# Test if var is above 5
if [[ "$var" > "$a" ]]
 then 
 echo "test failed" # Var is higher than 5
 exit $ER_AF