Aloha everyone,
I have created a small bash shell script which I wanted to use with GeekTool, but I have experienced different results using the same script on my iMac (11,1) and my MacBook Pro (8,3). I'm pulling network data using both networksetup and system_profiler. What I have thus far are several calls to both, but would like to consolidate it to one call to each process creating variables to use in my script. Here is my script thus far:
# Get Ethernet and Wi-Fi information and display it for GeekTool
WiFi=$(networksetup -getairportnetwork en1 | awk '{print $4 " " $5 " " $6 " " $7 " " $8}')
WiFi_IP=$(networksetup -getinfo Wi-Fi | grep -v IPv6 | awk '/IP address/ {print $3}')
SubMask=$(networksetup -getinfo Wi-Fi | awk '/Subnet mask/ {print $3}')
S2N=$(system_profiler SPAirPortDataType | awk '/Noise/ {print $4 " " $5 " " $6 " " $7 " " $8}')
TRate=$(system_profiler SPAirPortDataType | awk '/Rate/ {print $3 " Mbps"}')
echo -e "\033[4;33m" AirPort
if [ "$WiFi_IP" = "" ];
then echo "Not connected to wireless AP."
else echo -e "Wi-Fi AP: " $WiFi "\nIP Address: " $WiFi_IP "\nSubnet Mask: " $SubMask "\nTransmit Rate: " $TRate
fi
EthIP=$(networksetup -getinfo Ethernet | grep -v IPv6 | awk '/IP address/ {print $3}')
EthSubMask=$(networksetup -getinfo Ethernet | grep -v IPv6 | awk '/Subnet mask/ {print $3}')
echo -e "\033[4;33m" "\nEthernet"
if [ "$EthIP" = "" ];
then echo "Not connected to wired network."
else echo -e "IP Address: " $EthIP "\nSubnet Mask: " $EthSubMask
fi
When I create a shell in GeekTool and enter the path to my script, everything works fine on my MacBook Pro, but on my iMac, GeekTool displays the results fine once, then upon the refresh (I had it set for 15s), the result disappear and never returns to the screen. While I know that what I have works, it makes too many calls to both processes and I would like to consolidate it to one call per process, extracting the desired information into a container such as an array from which I can access said desired information.
In other words, does anyone know how I can make just one call to networksetup to get all the information gathered from both -getairportnetwork en1 and -getinfo Wi-Fi as well as system_profiler SPAirPortDataType (which takes the longest - around 5-8 seconds each time)?