I'm trying to telnet to a McData switch via a
perl script to display port information. This script stopped working on some switches who've had their firmware upgraded.
Here's the script:
#!/usr/bin/
perl
use Net::Telnet;
$mySwitch = shift || die "command needs arguments, perl_telnet.pl <switch_name>";
$myPassword = "password";
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die');
$telnet->open("$mySwitch");
$telnet->waitfor('/Username: $/i');
$telnet->print('Administrator');
$telnet->waitfor('/Password: $/i');
$telnet->print("$myPassword");
print $telnet->cmd('show port status');
print $telnet->cmd('logout');
----------------------------
This works for most switches but the ones that dont display the following error:
pattern match read eof at <path to script>l line 18
What does this mean? I cant tell which step this is failing. The following is displayed when doing a telnet to the switch that works:
Connected to switch.company.com.
Escape character is '^]'.
Username: Administrator
Password:
Root>
This switch doesn't work and you can see below that the reponse from the telnet session to the switch is the same:
Connected to switch.company.com.
Escape character is '^]'.
Username: Administrator
Password:
Root>
Does my patter matchin jive? I think there may be some control character in there in the new switch. How do I mod the
perl script to ignore these things?