Log 'ip route show table' errors to corresponding error file
authorMichael Prokop <mika@grml.org>
Fri, 5 Mar 2021 16:06:50 +0000 (17:06 +0100)
committerMichael Prokop <mika@grml.org>
Fri, 5 Mar 2021 16:36:44 +0000 (17:36 +0100)
We are iterating over the defined tables in /etc/iproute2/rt_tables,
though for tables that don't exist, ip reports an ugly error message,
that's a bit confusing during execution within grml-hwinfo:

| root@grml ~ # grep -v '^#' /etc/iproute2/rt_tables
| 255     local
| 254     main
| 253     default
| 0       unspec
| root@grml ~ # ip route show table 253
| Error: ipv4: FIB table does not exist.
| Dump terminated

Instead, store its error message to an according error file.

grml-hwinfo

index b5329b3..ab2b295 100755 (executable)
@@ -261,7 +261,7 @@ cd "${OUTDIR}" || exit 1
   exectest ip && ip route show     > ip_route
   exectest ip && if [ -r /etc/iproute2/rt_tables ] ; then
                    grep -v '^#' /etc/iproute2/rt_tables | while read table _ ; do
-                     ip route show table "${table}" > "ip_route_table_${table}"
+                     ip route show table "${table}" > "ip_route_table_${table}" 2> "ip_route_table_${table}".error
                    done
                  fi
   exectest ip && ip rule show      > ip_rule