I am trying to make a python program to display information about the WiFi connection, but I have hit a snag. subprocess.check_output() is not working the way I need it to.
>>>import subprocess
>>>test = subprocess.check_output("iwconfig")
Provides me with the following: enp9s0 no wireless extensions.
virbr0-nic no wireless extensions.
virbr0 no wireless extensions.
lo no wireless extensions.
But when I go into a terminal and do the same command, it provides me with this:
wlp4s0 IEEE 802.11abgn ESSID:[Network Name]
Mode:Managed Frequency:5.2 GHz Access Point: [access point]
Bit Rate=81 Mb/s Tx-Power=14 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=36/70 Signal level=-74 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:26 Missed beacon:0
enp9s0 no wireless extensions.
virbr0-nic no wireless extensions.
virbr0 no wireless extensions.
lo no wireless extensions.
Can anyone tell me how to fix this (my goal is to get all of the information that I get when I run it in the terminal when I use python to run it). I tried looking at the docs, but I do not understand everything said there. Thank you in advance.
Some of the output may be going to stderr.
test = subprocess.check_output("iwconfig", stderr=subprocess.STDOUT)