4 Einträge, 1 Seite |
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/perl -w
use strict;
use Net::Telnet::Cisco;
my $input = '';
my ($prematch,$match);
use constant HOST => 'TERMINAL SERVER';
use constant USER => 'USER';
use constant PASS => 'PASSWORT';
use constant COMMAND => 'ts_menu';
use constant TIMEOUT => '60'; # Wartezeit 60 Sekunden
use constant PROMPT => '/[# >]*$/';
my $glob;
my $IOSversion;
my $platform;
use constant ROUTER_PROMPT => '/^\s*[\w().-]*[\$#>]\s?(?:\(enable\))?\s*$/'; #Standart Cisco Prompt
#####################################################
#
#Anmeldung an Cyclades Terminal Server
#
#######################################################
my $telnet = Net::Telnet::Cisco->new( Host =>HOST,
Input_log => 'input.log',
Errmode =>'die',
Prompt => '/[\$%#>:] $/',
Timeout => TIMEOUT);
$telnet->login(USER,PASS);
$telnet->input_log(*stdout);
$telnet->cmd ( String => COMMAND,
Timeout => TIMEOUT,
Prompt => '/[\$%#>:] $/',
# Errmode =>'die',
# Errmode =>'return',
);
chomp(my $Port = <STDIN>);
#################################################
#
#Auswahl Port des TS
#
#################################################
$telnet->cmd ( String => $Port,
Timeout => TIMEOUT,
Prompt => '/\n/',
# Errmode =>'die',
# Errmode =>'return',
);
################################################ ok
$telnet->waitfor( match =>'/\n/');
$telnet->cmd ( String => '',
Timeout => TIMEOUT,
Prompt => ROUTER_PROMPT,
# Errmode =>'die',
Errmode =>'return',
);
###############################################
#
# Router/Switch
#
###############################################
$telnet->waitfor( match =>'/[# >]*$/');
$telnet->cmd('terminal length 0');
# Enable mode
$telnet->waitfor( match =>'/[# >]*$/');
$telnet->cmd('enable');
################################################
my @testvar = $telnet->cmd("sh ver");
print "Test\n";
#$telnet->waitfor( match =>PROMPT);
#$telnet->normalize_cmd;
#$telnet-> cmd (String => $Version,
# Prompt => PROMPT,
# );
my @sh_ver = $telnet->cmd('show ver');
&error_check($telnet);
foreach (@sh_ver) {
if ($_ =~ /^IOS.*Version ([\w.()]+)/) {
print "Version found: $1\n";
$IOSversion = $1;
$IOSversion =~ s/[).]//g;
$IOSversion =~ s/\(/-/;
}
if ($_ =~ /^cisco (\w+\d+)/) {
print "Platform found: $1\n";
$platform = $1;
}
if ($_ =~ /Catalyst (\d+)/) {
$platform = "Catalyst_" . $1;
}
}
$platform = $platform . "_$IOSversion";
################################################
$telnet->close;
4 Einträge, 1 Seite |