use Net::Telnet; use strict; my $username = "standarduser"; my $passwd = "standardpass"; my $base = "10.20.16"; my $start = 0; my $end = 256; my $t = new Net::Telnet (Timeout => 1, Prompt => '/<.> $/', Errmode => 'return'); if (defined $ARGV[0]){ $start = $ARGV[0]; } if (defined $ARGV[1]){ $end = $ARGV[1]; } for (my $i=$start; $i<$end; $i++){ $t->close unless $i==$start; print "Trying $i\n"; next unless $t->open("$base.$i"); next unless $t->login($username, $passwd); my @lines = $t->cmd("pwd"); print "$base.$i => $lines[1]\n"; #next command prompt }