1
#!/bin/bash
MAX=20
while true
do
iwconfig wlan0 txpower $(((RANDOM % $MAX) +1))
set -x #this was not originally included
echo iwconfig wlan0 | grep Tx-Power
done

So I am trying to have a small script vary the tx power of my device below the max. I had this working no problem a while back and have revisted the script now. Since then I have changed host and VM that this is running on and without the set-x it just hangs. Each line works individuall, but it will not output the echo to the screen when in a script.

When I add the set -x it works but also echos set -x, done etc to the screen also.

Any idea what has caused this change and how I could fix

A

  • What is this line meant to do?: echo iwconfig wlan0 | grep Tx-Power – Wayne Vosberg Jul 13 '17 at 12:41
  • it should run the iwconfig command, pipe the output to grep and then grep should pull the Tx-Power bit from the command and display it to screen. Essentially I want a running list of what the power output of the card is, this should be displayed without other content – crashoveride Jul 13 '17 at 12:47

1 Answers1

1

Your script runs in a endless loop It also contains the following line:

 echo iwconfig wlan0 | grep Tx-Power

so you simply echo string "iwconfig wlan0" and then you try to find "Tx-Power" in this script.

change this line to:

iwconfig wlan0 | grep Tx-Power

so at least you will be able to see Tx-Power in the output.

gbajson
  • 1,531
  • 13
  • 32
  • Thanks very much that has it back how I wanted it! – crashoveride Jul 13 '17 at 13:10
  • @crashoveride, if this solved your problem, and you now understand why the problem occurred, please close the question by clicking the checkmark to the left of the answer. – ghoti Jul 13 '17 at 13:14