hi
hello everybody
i'm using the foxboard to build a copy-station for usb-devices. i'm a
complete newbie to linux and embedded systems. i had a partner for
this project who was a linux-freak but unfortunately he died in an
motorcycle accident a two weeks ago and now i have to do the software
too until wednesday
i made a simple board with 5 switches and 5 leds to control the
foxbord without the need for a terminal using a shellscript (i imagined)
the switches are connected to the bits 3, 5, 16, 18 and 20 of port G
i want to make a small shell-skript that does the following
1. readbits -p g (without a switch pressed it returns
XXXXXXX11111111111111111XX11111X)
2. i want to repeat the readbits -p g commando as long as no switch is
pressed (polling) so i write the return-value of each readbit into a
variable
IN=`readbits -p g`
3. if switch 1 is pressed the value of readbits changes to
XXXXXXX11111111111111111XX11011X.
if i try to compare $IN with the string
"XXXXXXX11111111111111111XX11011X" and execute the commandos needed
for switch 1 (dd /dev/sda/0 /dev/sda/1) it does not jump into the
if-loop, even if i compare to the standard-value and press no switch
and even worse than that, when i execute the script it ends with an
error saying "XXXXXXX11111111111111111XX11111X: unexpected operator"
(this is the result from readbits) so i guess it ends with the
return-value of the readbit-command as an input into the shell
is anybody here able to help me please? and please excuse my bad english
here is the complete code:
#!/bin/sh
IN=`readbits -p g` //i tried IN="echo `readbits -p g`" too
if [ $IN = "XXXXXXX11111111111111111XX11111X" ] //tried ${IN} and
echo $IN and "$IN"
then
echo "this should be the code to jump to"
else
echo "wrong part of the if-condition"
fi
so in short: i want to assign the output of readbits -p g to a
variable called IN, then i want to check the value of IN against the
five possible results (1 for every switch) using if-conditions
anyone have ideas? i want to keep it as simple as possible...