vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| The bash program below is a (test) program to test the values of a USB interface card. The lines in front are only for clarification. When an input port on the USB card gets activated, then the variable digital_inputs changes (in line 11). I checked that with line 12 The next time the while statement executes (in line 8) it should be false, and the while loop should stop. This doesn't happen. What is my mistake? (don't get a syntax error) 1#!/bin/bash 2 3 digital_inputs=0 4 portstatus_dec=0 5 6 7 8 while [ $digital_inputs=$portstatus_dec ]; 9 do 10 sleep 1 11 digital_inputs=`k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2` 12 echo $digital_inputs 13 done 14 15 echo "There is an alarm" |
| |||
| On Wed, 27 Feb 2008 21:01:49 +0100, Henk Oegema wrote: > The bash program below is a (test) program to test the values of a USB > interface card. > > The lines in front are only for clarification. > > When an input port on the USB card gets activated, then the variable > digital_inputs changes (in line 11). > I checked that with line 12 > The next time the while statement executes (in line 8) it should be > false, and the while loop should stop. > > This doesn't happen. > > What is my mistake? (don't get a syntax error) > > > > 1#!/bin/bash > 2 > 3 digital_inputs=0 > 4 portstatus_dec=0 > 5 > 6 > 7 > 8 while [ $digital_inputs=$portstatus_dec ]; 9 do In a test, you need a space on each side of the equals sign. > 10 sleep 1 > 11 digital_inputs=`k8055 -m:1 2>/dev/null | tail -1 | cut -d';' > -f2` 12 echo $digital_inputs > 13 done > 14 > 15 echo "There is an alarm" |
| |||
| El Tux <nope@spamsucks.invalid>: > On Wed, 27 Feb 2008 21:01:49 +0100, Henk Oegema wrote: > > > > 1#!/bin/bash > > 2 > > 3 digital_inputs=0 > > 4 portstatus_dec=0 > > 8 while [ $digital_inputs=$portstatus_dec ]; > > In a test, you need a space on each side of the equals sign. And, to quote Ben at linuxgazette.net, *always* double-quote your variables. They may be empty. > > 10 sleep 1 > > 11 digital_inputs=`k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2` > > 12 echo $digital_inputs > > 13 done > > 14 > > 15 echo "There is an alarm" -- Any technology distinguishable from magic is insufficiently advanced. (*) http://blinkynet.net/comp/uip5.html Linux Counter #80292 - - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me. |
| ||||
| Henk Oegema <henk@oegema.com> writes: >The bash program below is a (test) program to test the values of a USB >interface card. >The lines in front are only for clarification. >When an input port on the USB card gets activated, then the variable >digital_inputs changes (in line 11). >I checked that with line 12 >The next time the while statement executes (in line 8) it should be false, >and the while loop should stop. >This doesn't happen. >What is my mistake? (don't get a syntax error) Put spaces on either side of the = in test. >1#!/bin/bash >2 >3 digital_inputs=0 >4 portstatus_dec=0 >5 >6 >7 >8 while [ $digital_inputs=$portstatus_dec ]; >9 do >10 sleep 1 >11 digital_inputs=`k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2` >12 echo $digital_inputs >13 done >14 >15 echo "There is an alarm" |
| Thread Tools | |
| Display Modes | |
| |