#!/usr/bin/perl use strict; use warnings; use Net::Telnet; $|=1; my $t = new Net::Telnet (Timeout => 10, Telnetmode => 0); my $username = "user"; my $password = "pass"; $t->open("192.168.10.199"); #ip des switches $t->waitfor('/login:.*$/') or die "no login prompt: ", $t->lastline(); $t->print($username); $t->waitfor('/password:.*$/') or die "no password prompt: ", $t->lastline(); $t->print($password); $t->waitfor('/save your configuration/') or die "login not successful: ", $t->lastline(); $t->print("show ports configuration no-refresh"); #befehl der den Status der Ports ausgibt my $stay_while = 1; while($stay_while) { my $line = $t->getline(); chomp($line); print $line."\n"; if($line =~/indicates/) #wenn das zugrifft, dann ist die Ausgabe beendet. { $stay_while = 0; } }