]>
git.proxmox.com Git - mirror_frr.git/blob - tools/zc.pl
2 # SPDX-License-Identifier: GPL-2.0-or-later
4 ## Zebra interactive console
5 ## Copyright (C) 2000 Vladimir B. Grebenschikov <vova@express.ru>
12 my $host = `hostname -s`; $host =~ s/\s//g;
14 my $server = 'localhost';
17 &getopts
('l:e:czborh');
23 my $login_pass = $opt_l || $ENV{ZEBRA_PASSWORD
} || 'zebra';
24 my $enable_pass = $opt_e || $ENV{ZEBRA_ENABLE
} || '';
26 my $port = ($opt_z ?
'zebra' : 0) ||
27 ($opt_b ?
'bgpd' : 0) ||
28 ($opt_o ?
'ospfd' : 0) ||
29 ($opt_r ?
'ripd' : 0) || 'zebra';
31 my $cmd = join (' ', @ARGV);
33 my $t = new Net
::Telnet
(Timeout
=> 10,
34 Prompt
=> '/[\>\#] $/',
39 $t->cmd ($login_pass);
41 $t->cmd (String
=> 'en',
42 Prompt
=> '/Password: /');
43 $t->cmd ($enable_pass);
45 $t->cmd ('conf t') if "$opt_c";
53 my $prompt = sprintf ("%s%s# ", $host,
54 ($port eq 'zebra') ?
'' : "/$port");
56 print "\nZEBRA interactive console ($port)\n\n" if -t STDIN
;
61 print $prompt if -t STDIN
;
65 print "\n" if -t STDIN
;
68 exit (0) if ($cmd eq 'q' || $cmd eq 'quit');
70 docmd
($t, $cmd) if $cmd !~ /^\s*$/;
79 my @lines = $t->cmd ($cmd);
80 print join ('', grep (!/[\>\#] $/, @lines)), "\n";
85 print "USAGE: $0 [-l LOGIN_PASSWORD] [-e ENABLE_PASSWORD] [-z|-b|-o|-r|-h] [<cmd>]\n",
86 "\t-l - specify login password\n",
87 "\t-e - specify enable password\n",
88 "\t-c - execute command in configure mode\n",
89 "\t-z - connect to zebra daemon\n",
90 "\t-b - connect to bgpd daemon\n",
91 "\t-o - connect to ospfd daemon\n",
92 "\t-r - connect to ripd daemon\n",