in reply to use telnet to router with expect

"Does not run" meaning the spawn fails? Or at a later step? You might want to add an
or die "Expect spawn failed, error $!";
to the end of your spawn command - that might tell you WHY it's failing...

I assume 000.000.000.000 isn't the IP address you're actually using - but if it is, that would explain the failure :)


Mike

Replies are listed 'Best First'.
Re^2: use telnet to router with expect
by fionbarr (Friar) on Mar 14, 2014 at 13:52 UTC
    thanks Mike...everything works except the 'show inventory' command. The login succeeds and I see the router prompt. At that point, the script says: 'print $command "show inventory"' and the command does not execute.
      Interesting...

      I'd download a copy of wireshark (a.k.a. tcpdump) and look at what goes over the wire when you do the command interactively with telnet - perhaps there's a \r sent somewhere you're using a \n, for example.


      Mike
      Another possibility - maybe "hard_close" is closing the command before the server can respond?

      What happens if you switch that to "soft_close", or even expect something you'd see at the end of the inventory before closing?


      Mike