The response to my recent tweet about trying to run Cisco commands on Linux got me thinking: why shouldn’t i be able to type show run on my Linux routers? For those of us who switch between Linux & Cisco (and possibly others) a lot and use the Quagga routing suite, here’s a ridiculously obvious snippet to add to ~/.bashrc:
VTYSH="`which vtysh 2>/dev/null`"
if [ -x "$VTYSH" ]; then
$VTYSH -c "show $*"
Why didn’t i think of this before? It doesn’t handle quoting very well (i coudn’t find a way to make "$@" do the right thing), but it should be good enough to make lots of commands work pretty well, like:
- show ip protocols
- show ip route (the output of which seems much more natural to me than netstat -rn since i’ve been doing CCNA & CCNP studies)
- show running-config
- and even show ip ospf neighbor
The above code will not define the show function if it can’t find vtysh on the PATH, so on hosts without quagga installed, it will have no effect (other than setting the VTYSH variable to the empty string). Hat tip to Rob Gilreath for sparking the thought.