
like the following work as expected. #!/bin/sh if ! route -sn get default >/dev/null 2>&1; then echo default gateway not set exit 1 fi echo default gateway set Handle routing socket write(2) errors when they occur. This produces better diagnostics by allowing for handling of the special route errno values ESRCH, EBUSY, and ENOBUFS even with the quiet (-q) option or when doing a get command.