[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quagga-users
Subject:    [quagga-users 11244] Re: non interactive vtysh
From:       Adam Przybyla <adam () ertel ! com ! pl>
Date:       2009-12-11 13:02:49
Message-ID: 20091211130249.GA31441 () smtp ! ertel ! com ! pl
[Download RAW message or body]

On Tue, Dec 08, 2009 at 07:58:31AM -0600, vlad_goreletsky@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@hacker ~]# show ru|inc ip
ip forwarding
!
[root@hacker ~]# echo "ip ro 10.10.0.0/24 10.0.0.1"|conf
[root@hacker ~]# show ru|inc ip
ip route 10.10.0.0/24 10.0.0.1
!
ip forwarding
!
[root@hacker ~]# echo "ip ro 10.20.0.0/24 10.0.0.1"|conf
[root@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@hacker ~]# echo "no ip ro 10.20.0.0/24 10.0.0.1"|conf
[root@hacker ~]# echo "no ip ro 10.10.0.0/24 10.0.0.1"|conf
[root@hacker ~]# show ru|inc ip
ip forwarding
!
[root@hacker ~]# show ver
Quagga 0.99.11 ().
Copyright 1996-2005 Kunihiro Ishiguro, et al.
[root@hacker ~]# echo $SHELL
/bin/bash
[root@hacker ~]#
Regards
								Adam Przybyla
_______________________________________________
Quagga-users mailing list
Quagga-users@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic