Artificial intelligent assistant

ping over wlanX when X is unknown I've been running a bash script which updates the hosts table and tests a connection to a specific host. It runs successfully on a number of machines. Along the way, it checks communication with a given host using ping -I wlan0 <host> and ping -I eth0 <host> This worked fine until I tried using it on a machine whose (one and only) wireless device is a victim of udev shenanigans (similar to this), sometimes using wlan0 and other times wlan1. Is there a reliable way of writing my bash script to ping with an arbitrary wlanX device, short of writing code for identifying which one the machine prefers to use on a given day?

You can identify the interface used with this command (run as root) :


iwconfig 2>/dev/null | grep -o "^\w*"


and the output will be, for example :


wlan0


You have to save the answer in a variable in your script

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0f6d6e25c877f1ccc270fd76ee43dccb