[quagga-users 11244] Re: non interactive vtysh

Adam Przybyla adam at ertel.com.pl
Fri Dec 11 13:02:49 GMT 2009


On Tue, Dec 08, 2009 at 07:58:31AM -0600, vlad_goreletsky at lexpr.ru wrote:
> Hello
> 
> "Can anybody find me sombody to..."
> 
> Please, help with vtysh.
> 
> Some tasks need to execute commands in command mode, something like [vtysh
> -c "command string"].
> 
> If I execute commands in interactive mode, I have no problems.
	... try this:

show() { vtysh -c "show $*";}
copy() { vtysh -c "copy $*";}
list() { vtysh -c "list $*";}
no() { vtysh -c "no $*";}
undebug() { vtysh -c "undebug $*";}
debug() { vtysh -c "debug $*";}
wr()   { vtysh -c "wr";}
inc() { sed -n "/^$*/,/^.$/p"; }
include() { sed -n "/^$*/,/^.$/p"; }
conf() { ( echo "conf t";cat; ) | vtysh >/dev/null; }

Examples:
[root at hacker ~]# show ru|inc ip
ip forwarding
!
[root at hacker ~]# echo "ip ro 10.10.0.0/24 10.0.0.1"|conf
[root at hacker ~]# show ru|inc ip
ip route 10.10.0.0/24 10.0.0.1
!
ip forwarding
!
[root at hacker ~]# echo "ip ro 10.20.0.0/24 10.0.0.1"|conf
[root at hacker ~]# show ru|inc ip
ip route 10.10.0.0/24 10.0.0.1
ip route 10.20.0.0/24 10.0.0.1
!
ip forwarding
!
[root at hacker ~]# echo "no ip ro 10.20.0.0/24 10.0.0.1"|conf
[root at hacker ~]# echo "no ip ro 10.10.0.0/24 10.0.0.1"|conf
[root at hacker ~]# show ru|inc ip
ip forwarding
!
[root at hacker ~]# show ver
Quagga 0.99.11 ().
Copyright 1996-2005 Kunihiro Ishiguro, et al.
[root at hacker ~]# echo $SHELL
/bin/bash
[root at hacker ~]#
Regards
								Adam Przybyla


More information about the Quagga-users mailing list