-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_conf_exos.pl
50 lines (40 loc) · 1.15 KB
/
get_conf_exos.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
use strict;
use Net::Telnet;
use POSIX qw(strftime);
my @nethost = ("........");
my $netport = "........";
my $h_log = "........";
my $h_pass = '........';
my $cur_date = strftime "%G%m%d", localtime;
my $prompt = '/\S+ # $/';
my $dir = "........";
my $d_perm = "0755";
my $f_perm = "644";
unless (-d "$dir/$cur_date") {
mkdir "$dir/$cur_date", oct($d_perm);
}
for (my $j = 0; $j <= $#nethost; $j++) {
unless (-d "$dir/$cur_date/$nethost[$j]"){
mkdir "$dir/$cur_date/$nethost[$j]", oct($d_perm);
}
my $ts = Net::Telnet->new(Timeout => 60, Prompt => $prompt);
$ts->open(Host => $nethost[$j], Port => $netport);
$ts->login($h_log,$h_pass);
$ts->cmd("disable clipaging");
my @cfg_all = $ts->cmd("show configuration");
open(FILE, ">$dir/$cur_date/$nethost[$j]/$nethost[$j].conf");
print FILE "@cfg_all";
close(FILE);
my @p_a = $ts->cmd("show policy");
splice(@p_a,0,3);
chomp (@p_a);
for (my $i = 0; $i <= $#p_a; $i++) {
my $p_n = substr $p_a[$i], 0, index($p_a[$i], " ");
my @tmp_p = $ts->cmd("show policy $p_n");
open(FILE, ">$dir/$cur_date/$nethost[$j]/$p_n.pol");
print FILE "@tmp_p";
close(FILE);
}
$ts->close;
}