Thread Terminal Server / Router Konfiguration: Konfiguartion von Cisco Routern über TS (3 answers)
Opened by Henk at 2004-03-11 15:04

Henk
 2004-03-11 15:04
#80871 #80871
User since
2004-03-11
2 Artikel
BenutzerIn
[default_avatar]
Hallo zusammen,
ich bin relativer Neuling in Sachen Perl (hier übrigens auch), und habe ein ganz grosses Problem:
Ich schreibe ein Script mit dem man über ein "Cyclades" Terminal Server Cisco Router/Switche konfigurieren kann (zumindest irgenwann wann mal). Die Anmeldung am TS funktioniert auch und auch auf den Router komme ich drauf. Jedoch kann ich auf dem Router nur einen Befehl absetzen, danach ist Schicht es kommt ein "command timed-out". Es ist egal was für einen Befehl ich absetze...der erste funktioniert, danach nichts mehr.
Wenn ich "per Hand" über den TS auf den Router gehe funktioniert alles.
Hier ist ein großteil meines Scripts...hoffe es ist hier erlaubt soviel reinzustellen.
Code: (dl )
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;


Wäre sehr dankbar wenn mir irgendjemand weiterhelfen kann. Bei Fragen bitte fragen und wie gesagt ich bin fast Neuling.

View full thread Terminal Server / Router Konfiguration: Konfiguartion von Cisco Routern über TS