#!/usr/bin/perl -w use strict; use Net::Telnet; my $log = './log.txt'; open LOG, ">>$log"; #open log file - append mode open IPS, "){ my $ip = $_; #current iteration (line) of IPs file $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die' Prompt => '/# $/i'); $telnet->open($ip); $telnet->login('USERNAME', 'PASSWORD'); if($telnet->cmd('CommandA')){ print LOG "$ip CommandA successful"; }else{ print LOG "$ip Unable to Connect"; } } close LOG; #close files close IPS;