[quagga-dev 5320] Re: how to communicate with quagga daemons?

Andrew J. Schorr aschorr at telemetry-investments.com
Mon Apr 28 23:17:09 BST 2008


Hi,

On Mon, Apr 21, 2008 at 06:42:44PM +0800, huhao wrote:
> 	char *msg[] ={
> 		"zebra\n",
> 		"enable\n",
> 		"zebra\n",
> 		"configure terminal\n",
> 		"interface eth0\n",
> 		"ip address 133.144.10.1/24\n",
> 		"quit\n",
> 		"write\n",
> 	};

FYI, this can easily be done without writing C code,
using existing vtysh capabilities:

   bash-3.1$ vtysh --help
   Usage : vtysh [OPTION...]

   Integrated shell for Quagga routing software suite. 

   -b, --boot               Execute boot startup configuration
   -c, --command            Execute argument as command
   -d, --daemon             Connect only to the specified daemon
   -E, --echo               Echo prompt and command in -c mode
   -C, --dryrun             Check configuration for validity and exit
   -h, --help               Display this help and exit

   Note that multiple commands may be executed from the command
   line by passing multiple -c args, or by embedding linefeed
   characters in one or more of the commands.

   Report bugs to http://bugzilla.quagga.net

I think the following should probably do the same thing as your
C code, with much less work (but I have not tested this):

   vtysh -d zebra \
      -c "configure terminal" \
      -c "interface eth0" \
      -c "ip address 133.144.10.1/24" \
      -c "quit" \
      -c "write"

Regards,
Andy



More information about the Quagga-dev mailing list