From: Bryan B. <br...@bu...> - 2007-03-21 20:30:22
|
> Hello, > > I am experiencing some strange behavior when combining Expect with > Net::Telnet when telnet'ing to Cisco 1924 switches. > > Scenario: > > Cisco Gear > > 1924's newer than 1924's > +----------+---------------------+ > Net::Telnet | works | works | > Expect spawning system telnet | works | works | > Expect using Net::Telnet | no work | works | > +----------+---------------------+ > > The reason I am concerned with using Net::Telnet with Expect is I have > designed my program to be multithreaded and from what I read Net::Telnet > is thread safe whereas IO-Tty is not. > I have used threading with expect on top of Net::Telnet successfully. Spawning a system telnet will, obviously, not work. > The symptoms of what happens when using Expect and Net::Telnet to telnet > to a 1924 is this: > > telnet negotiation (non printable characters) happens and then it looks > like no other traffic is sent from the remote side. I am currently > combing through tcpdump and wireshark analysis of this, but I thought I > would send an email to the list to see if anyone had any ideas in the > meantime. > > Here is some code that demonstrates what is happening: > #!/usr/bin/perl > > use strict; > use Expect; > use Net::Telnet (); > > print "\n\n-----------START OF Net::Telnet-----------\n"; > > my $t = new Net::Telnet("ghAS1.d.umn.edu"); > my @lines = $t->waitfor('/Selection.*/'); > print "@lines\n"; > > print "\n\n-----------END OF Net::Telnet-----------\n"; > print "\n\n-----------START OF Expect with Net::Telnet-----------\n"; > > my $e = new Net::Telnet("ghAS1.d.umn.edu"); > my $exp = Expect->exp_init($e); > $exp->log_stdout(1); > &expect_selection($exp); > Try this bit of code: -- snip --> my $e = new Net::Telnet(Prompt => '/Selection.*/'); $e->open("ghAS1.d.umn.edu"); my $exp = Expect->exp_init($e); $exp->log_stdout(1); &expect_selection($exp); <-- end -- The open() method should finish the handshaking for you. Also, if you have to log in, it might help to do that within the Net::Telnet object prior to expecting on top: $e->login($user, $password); Hope that helps. Bryan http://sourceforge.net/projects/rover |