For me, the best way to find the best interface to use is to get it by routing:
$ ip route | grep ^default | awk '{print $5}'
(no need to know which name it have)
This command return nothing on my Fedora instance.
Not sure it would be easy to found an universal shell command which could easily grep this network interface name.
The best way would be to match them all with a JavaScript regex.
$ ip route | grep ^default | awk '{print $5}'
This command return nothing on my Fedora instance.
Sorry, it was not a real proposition of code to use, but more to show the logic i use to obtain interface name. Start from the routing table and select default gateway to get interface name... But it's much more complicated to do that in js! For now, the regex seems very good ;-)