Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I am not able to login onto DSL Switch using perl code, Same script on other switch from other vendors is successful without any issues. From past 2 weeks I am re-writing the code in different ways but no success. Seems like the Telnet server based on the VxWorks Target is having minute details that I am not able to understand. Please help me to solve this puzzle.

use IO::Socket; #============Main=============== my $sock; $sock=login_router(); print $sock; exit; #============End=============== sub login_router { my $socket; $socket = new IO::Socket::INET (PeerAddr => "192.168.1.240", + PeerPort => "23" , Proto => 'tcp') ; if ($socket) { print "Connection is established\n"; } else { die "Error: $!"; } sleep(4); $socket->autoflush(); my $input = ""; my $char = ""; until ($input =~ /Login :/){ $socket->sysread($char, 1); $input .= $char; } print $input; # Write the login name syswrite $socket, "ecidslam\r\n"; sleep(2); # Wait for the Password prompt my $input = ""; my $char = ""; until ($input =~ /Password :/){ $socket->sysread($char, 1); $input .= $char; } print $input; syswrite $socket, "Hi-FOCuS\r\n"; # To read the output from the socket while(<$socket>) { last if (/welcome/); die "Exit... Login error\n" if (/Permission Denied/); # Print each line read from socket print $_; } return $socket; }

On Executing Perl code following is the trace

C:\Perl>perl login.pl Connection is established VxWorks vxTarget Login : v? ²? ¦?am Password :******** Exit... Login error

Login using hyperterminal

Manual login onto the DSL Swith will have following trace VxWorks vxTarget Login :ecidslam Password :******** Welcome IPNI >

Replies are listed 'Best First'.
Re: Login to ECI DSL switch fails always
by roboticus (Chancellor) on Mar 06, 2011 at 16:25 UTC

    Note: "Welcome" is not equal to "welcome". Either correct your regex, or add the "i" modifier.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.