$rtrs = "$workdir/bin/wanrtrs"; $outfile = "$workdir/$date-allnetrtrscn.raw"; open ($INR,$rtrs) || die "Can't open the file: $!\n"; open ($OUT,">>$outfile") || die "Can't open the file: $!\n"; while (<$INR>){ chomp(); push(@rtrs, $_); } foreach $host (@rtrs){ $remote = Net::SSH::Perl->new($host); $remote->login($user, $pass); if ( ! $remote ){ print "ERROR: Problem Connecting to $host\n"; $remote = Net::Telnet->new($host); $remote->login($user, $pass); } ($stdout) = $remote->cmd("sh ip vrf int"); print $OUT "$host:sh ip vrf int\n$stdout\n"; }