iproute2 has a message on fail that I do not know how to suppress.
I want to save the output of iproute2 to a variable for later use. if my network is up all is well and the output is something like:
sudo ip link set wlan0 up
ROUTE=$(ip route get 8.8.8.8)
printf "Route is:n${ROUTE}"
Route is:
8.8.8.8 via 192.168.1.1 dev wlan0 src 192.168.1.17 uid 1000
cache
If my network is down I get an unwanted artifact:
sudo ip link set wlan0 down
ROUTE=$(ip route get 8.8.8.8)
printf "Route is:n${ROUTE}"
RTNETLINK answers: Network is unreachable
Route is:
So I am not sure what is producing the message RTNETLINK answers: Network is unreachable
, or how to suppress this message.