I need some Specs and Data from Number of Latops in a ini-file.
When I try to get the IP-Adress with ip addr list <interface>
nothing happens in the script. Not even a Error.
I try to quote stuff in my code. Nothing change.
for w2 in /sys/class/net/wl*
do
w2i=$(basename $w2)
echo $w2i
addr=$(ip -o -4 addr list $w2i | awk '{print $4}' | cut -d/ -f1)
echo $addr
echo -e "$w2i=$addr"
done
I Think maybe it is because of the Varibales but this fails also (interface is set 'manually'):
for w2 in /sys/class/net/wl*
do
w2i=$(basename $w2)
echo $w2i
addr=$(ip -o -4 addr list wlp3s0 | awk '{print $4}' | cut -d/ -f1)
echo $addr
echo -e "$w2i=$addr"
done
When i run the script i get wlp3s0
and i must close the script with ctl-c. When i run ip -o -4 addr list wlp3s0 | awk '{print $4}' | cut -d/ -f1
it gives me my ip like i expected.
EDIT
I just need to wirte the full-path of the ip
-command. Can somebody explain why i have to do this? And especially it is not necessary for cut
or awk
that also based in /usr/bin/
?
for w2 in /sys/class/net/wl*
do
w2i=$(basename $w2)
echo $w2i
addr=$(/usr/bin/ip -o -4 addr list "$w2i" | awk '{print $4}' | cut -d/ -f1)
echo $addr
echo -e "$w2i=$addr"
done
}