Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Debian

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-2008, 07:01 PM
Henk Oegema
 
Posts: n/a
While loop problem

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"

Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:33 PM
El Tux
 
Posts: n/a
Re: While loop problem

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"


Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 04:16 AM
s. keeling
 
Posts: n/a
Re: While loop problem

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.
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 06:45 AM
Henk Oegema
 
Posts: n/a
Re: While loop problem

s. keeling wrote:

>
> And, to quote Ben at linuxgazette.net, *always* double-quote your
> variables. They may be empty.
>

Yep. :)
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 05:42 PM
Unruh
 
Posts: n/a
Re: While loop problem

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"


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Debian


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:53 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109