Kalyan
Kalyan

Reputation: 357

Output printing

When I use following echo statements I get a nice output which is what expected from such three separate echo statements:

echo AP $macaddr
echo noise floor $noise
echo $channel

Output:

AP ac:67:06:30:eb:00,
noise floor -96
channel=1

But when I change all three into one single 'echo' statement like the following, output breaks.

echo AP $macaddr noise floor $noise $channel

Output:

channel=06:30:eb:00, noise floor -96

In this output I don't see the channel and MAC Address is missing two of its first octets. What is causing this? How can avoid this?

Upvotes: 1

Views: 110

Answers (2)

Callie J
Callie J

Reputation: 31296

I don't know where channel comes from, but is there a spurious 'CR' at the start of the value of $channel or end $noise? Try doing:

channel=`echo $channel | tr -d '\r'`
noise=`echo $noise | tr -d '\r'`
echo AP $macaddr noise floor $noise $channel

...and seeing if that makes a difference. Failing that, see if there's any other dodgy chars in $channel and $noise (and any of the other variables):

echo $channel | od -t c

and if there are, use tr -d to remove them from the variable.

Upvotes: 5

LHMathies
LHMathies

Reputation: 2434

You have a carriage return at the end of $noise, so the output ' channel=0' (note initial space) is overwriting 'AP ac:67:0'.

Upvotes: 4

Related Questions