The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use telnet in script sibghat Shell Programming and Scripting 7 04-03-2007 04:38 AM
telnet through script arun.viswanath UNIX for Dummies Questions & Answers 1 03-26-2006 09:33 AM
ksh telnet script rwunwla Shell Programming and Scripting 5 12-16-2005 05:22 AM
telnet in a script vaccari UNIX for Dummies Questions & Answers 10 10-10-2001 08:37 AM
telnet in a script vaccari IP Networking 4 12-15-2000 11:42 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-03-2006
Registered User
 

Join Date: Feb 2006
Posts: 8
Help with borked Telnet script

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?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-06-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,334
I will make a guess... you are not waiting for the "Root>" prompt. Instead you just throw the commands at at the socket. Maybe the new firmware is slower or something.
Reply With Quote
  #3 (permalink)  
Old 03-20-2006
Registered User
 

Join Date: Jul 2005
Location: Mt. Prospect, Illinois
Posts: 32
Perl has a debug mode. I think its activated by appending the name with an
"-f", e.g. /usr/bin/perl -f. ' just a thought.

Mr-synapse
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0