I am trying to TELNET in my PERL script. I am able to issue commands, however, I need to verify that the commands ran succesfully. If not, the Program should abort with an error message. Below is my code, and I tried numerous coding to be able to exit with an error message, but was unsuccesful.
$telnet=new Net::Telnet ( Timeout=>10,Errmode=>'return',Prompt =>'/\$ $/i');
$telnet->open($host) or die $telnet->errmsg;
print "Connected to $host\n";
$telnet->login($ftpuser, $ftppass) or die $telnet->errmsg;
print "Logged in as User: $ftpuser \n";
print "\n\nChecking Remote Server Volume Status\n";
print $telnet->cmd($fverify);
print "\n\nChanging the Remote Server Volume Status to Backup\n";
$telnet->cmd($fbbackup) or die myerr();
print " Verify Volumes Mode\n";
print $telnet->cmd($fverify) or die $telnet->errmsg;
$telnet=new Net::Telnet ( Timeout=>10,Errmode=>'return',Prompt =>'/\$ $/i');
$telnet->open($host) or die $telnet->errmsg;
print "Connected to $host\n";
$telnet->login($ftpuser, $ftppass) or die $telnet->errmsg;
print "Logged in as User: $ftpuser \n";
print "\n\nChecking Remote Server Volume Status\n";
print $telnet->cmd($fverify);
print "\n\nChanging the Remote Server Volume Status to Backup\n";
$telnet->cmd($fbbackup) or die myerr();
print " Verify Volumes Mode\n";
print $telnet->cmd($fverify) or die $telnet->errmsg;