Page 1 of 1

trouble with perl and telnet

Posted: 22 Jul 2004 09:32
by cyplp
Hello

I need to manage some vls streamers by the telnet interface.

So I write a perl script for manage the server and I can't read the reply of telnet

code example :

Code: Select all

#!/usr/bin/perl use strict; use warnings; use Net::Telnet (); my $t; $t = new Net::Telnet(Port => 9999); #Prompt => '/\@vls>/'); $t->open("192.168.0.166"); $t->buffer; $t->waitfor('/Login:/'); $t->print("bozo"); $t->waitfor('/Password:/'); $t->print("bozo"); $t->print("help"); my @toto = $t->waitfor('/\@vls>/'); print "toto : @toto\n"; my @lines = $t->cmd("help"); print "lines : @lines\n"; $t->print("logout");
and I get this

Code: Select all

cyp@cyp:~$ perl telnet-test.pl toto : bozo @vls> command timed-out at telnet-test.pl line 28 cyp@cyp:~$

and I sniff the communication , I saw the reply and I don't understand why I can't read the reply :(

Posted: 06 Aug 2004 12:24
by cyplp
the next source code works ...

Code: Select all

#!/usr/bin/perl use strict; use warnings; use Net::Telnet (); my $t; $t = new Net::Telnet(Port => 9999); $t->open("192.168.0.166"); $t->waitfor('/Login:/'); $t->print("bozo"); $t->waitfor('/Password:/'); $t->print("bozo"); $t->waitfor('/\@vls>/'); $t->print("help"); my @toto = $t->waitfor('/\@vls>/'); print "toto : @toto\n"; $t->print("logout");