keep getting : not found

Code:
#!/bin/sh
# Latency menu 

while [ answer != "0" ] 
do
clear
echo "----------------------------------------"
echo "***     Lacency configuration        ***"
echo "----------------------------------------"
echo "Select a number and press Enter"
echo "  1  Set user defined Latency"


read -p " ?" answer
    case $answer in
        0) break ;;
        1)echo "Indtast din onskede latency" 
	  read user_latency
	   echo "Du skrev $user_latency"
	   my2="2"
	   echo "$my2"
	   test= `expr $user_latency / $my2`
	   echo "$test"
	   
	   ipfw pipe 1 config delay $test
 
can't figure out how to edit my tread so here are some more info :)

I'm starting to build my first sh script and I'm running into some problems , my only scripting / programming experience is from windows.

This is kinda working but i keep getting : not found in my echo "$test" , it does the calculation but it adds : not found. so a print would look like 500:not found
 
Figured it out my self , was a syntax error.

changed
Code:
test= `expr $user_latency / $my2`

to

Code:
test=`expr $user_latency / $my2`



thanks anyway for a great forum :)
 
There is builtin arithmetic parser, i.e. $((...)). It's supported by all ash descendants as well as bash/zsh.
Code:
$ user_latency=10
$ my2=2
$ echo $(( user_latency / my2 ))
5
 
In other words this
Code:
	   echo "Du skrev $user_latency"
	   my2="2"
	   echo "$my2"
	   test= `expr $user_latency / $my2`
	   echo "$test"
can be reduced to
Code:
echo "Du skrev $user_latency"
echo $(( my2 = 2 ))
echo $(( test = user_latency / my2 ))
 
Back
Top