I am building a new OSMC box using anb RPi4B device and the latest OSMC installer via Pi-Imager.
My devices report their network data via a call to a reporting function on my website when they boot and have been connected to the Internet.
On all of my other RPi systems I can use this command in the script to retrieve the active SSID:
WiFiSSID=$(iwconfig wlan0 | grep 'ESSID:' | sed -n 's/.*ESSID://p' | tr -d '"')
But on OSMC this does not work because iwconfig is not installed.
This is what I see when I check iwconfig and iw via apt:
$ apt policy iwconfig
N: Unable to locate package iwconfig
$ apt policy iw
iw:
Installed: (none)
Candidate: 5.9-3
Version table:
5.9-3 500
500 https://deb.debian.org/debian bullseye/main armhf Packages
Googling only brings up other similar commands all using a different function not existing on OSMC.
QUESTIONS:
-
Will installing iw somehow break the MyOSMC handling of wifi?
-
Is there a way in a script to ask the operating system on OSMC for the currently connected SSID? Without installing some other networking utility.
WiFiSSID=$(iw dev | sed -En 's/.*ssid.(.*)$/\1/p')
I have already tried iw, but it is not installed and I am worried that if I install it I would break the working WiFi handling of OSMC…
$ iw dev | sed -En 's/.*ssid.(.*)$/\1/p'
-bash: iw: command not found
There are other packages not installed as well, which I install if I need them.
But in this case I don’t know if installing iw will break whatever WiFi handler OSMC is using…
I thought that was in a default install since I had that but not iwconfig. It won’t pose an issue. Apparently I’ve had it installed long enough that I had forgot I installed it on my Vero V.
After I installed iw (sudo apt install iw -y
) I could do this:
WiFiSSID=$(iw dev | grep -A 7 wlan0 | grep ssid | awk '{print $2}')
WiFiLevel=$(iw dev wlan0 station dump | grep signal: | awk '{print $2}')
And I was suggested by my son-in-law to use ChatGPT instead of Google…
Got a working solution from a simple ask on ChatGPT
No you didn’t. You got an inelegant and easily broken solution when you already were given something that wasn’t…
osmc@VeroV:~$ iw dev | sed -En 's/.*ssid.(.*)$/\1/p'
JPS APE 2
osmc@VeroV:~$ iw dev | grep -A 7 wlan0 | grep ssid | awk '{print $2}'
JPS
osmc@VeroV:~$
1 Like
You could refer your future queries to ChatGPT.
2 Likes