I am trying to assign Link Quality (percentage) from iwconfig
to a variable in a .sh
file. This is for a conky theme I'm making. To do this I have the following:
lnk=$(iwconfig mlan0 | awk '/Link Quality/{split($2,a,"=|/");print int((a[2]/a[3])*100)}')
This command works if I enter it at the command line. However, in the script file it does not work or at least it doesn't seem to. I can put echo $lnk
right after and it returns nothing. The real kicker is, this was working before, but I changed distributions from Mint to MX Linux. I don't know how much that would affect anything but it's the only change I've made before this stopped working.
The other thing is, I also use a very similar script that was based on this one for battery level. It works great. But I can't understand why this one all of a sudden doesn't work anymore.
UPDATE - While I haven't yet figured out what was wrong, I did find a work-around. Instead of using a .sh file to get the information I wanted and manipulating it from there, I just decided to do it directly in the conky template. There's always more than one way to get the desired output.
Thanks anyway for what it's worth.
.sh
file. Are you sure it is executed in/bin/sh
, and not inbash
, for example? – Volker Siegel Oct 2 '19 at 5:30