]>
git.proxmox.com Git - mirror_frr.git/blob - tools/zc.pl
3 ## Zebra interactive console
4 ## Copyright (C) 2000 Vladimir B. Grebenschikov <vova@express.ru>
6 ## This file is part of GNU Zebra.
8 ## GNU Zebra is free software; you can redistribute it and/or modify it
9 ## under the terms of the GNU General Public License as published by the
10 ## Free Software Foundation; either version 2, or (at your option) any
13 ## GNU Zebra is distributed in the hope that it will be useful, but
14 ## WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ## General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with GNU Zebra; see the file COPYING. If not, write to the
20 ## Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ## Boston, MA 02111-1307, USA.
28 my $host = `hostname -s`; $host =~ s/\s//g;
30 my $server = 'localhost';
33 &getopts
('l:e:czborh');
39 my $login_pass = $opt_l || $ENV{ZEBRA_PASSWORD
} || 'zebra';
40 my $enable_pass = $opt_e || $ENV{ZEBRA_ENABLE
} || '';
42 my $port = ($opt_z ?
'zebra' : 0) ||
43 ($opt_b ?
'bgpd' : 0) ||
44 ($opt_o ?
'ospfd' : 0) ||
45 ($opt_r ?
'ripd' : 0) || 'zebra';
47 my $cmd = join (' ', @ARGV);
49 my $t = new Net
::Telnet
(Timeout
=> 10,
50 Prompt
=> '/[\>\#] $/',
55 $t->cmd ($login_pass);
57 $t->cmd (String
=> 'en',
58 Prompt
=> '/Password: /');
59 $t->cmd ($enable_pass);
61 $t->cmd ('conf t') if "$opt_c";
69 my $prompt = sprintf ("%s%s# ", $host,
70 ($port eq 'zebra') ?
'' : "/$port");
72 print "\nZEBRA interactive console ($port)\n\n" if -t STDIN
;
77 print $prompt if -t STDIN
;
81 print "\n" if -t STDIN
;
84 exit (0) if ($cmd eq 'q' || $cmd eq 'quit');
86 docmd
($t, $cmd) if $cmd !~ /^\s*$/;
95 my @lines = $t->cmd ($cmd);
96 print join ('', grep (!/[\>\#] $/, @lines)), "\n";
101 print "USAGE: $0 [-l LOGIN_PASSWORD] [-e ENABLE_PASSWORD] [-z|-b|-o|-r|-h] [<cmd>]\n",
102 "\t-l - specify login password\n",
103 "\t-e - specify enable password\n",
104 "\t-c - execute command in configure mode\n",
105 "\t-z - connect to zebra daemon\n",
106 "\t-b - connect to bgpd daemon\n",
107 "\t-o - connect to ospfd daemon\n",
108 "\t-r - connect to ripd daemon\n",