[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Net::Telnet Question

Ben Giddings

10/26/2006 3:03:00 PM

On Oct 25, 2006, at 22:37, William Ramirez wrote:
> So I've spent the last couple or so writing a rather trivial little
> ruby
> script to automate enabling and disabling an access list, mostly to
> become
> more familiar with Net::Telnet. I've run into an interesting issue
> I can't
> quite figure out.
>
...
> #cisco_device.cmd("exit") { |c| print c } #-----Confusing Line-----
>
> cisco_device.close
>
...
> If I uncomment out the last line, the series of commands works as
> intended
> (the access list is applied), and the following output is displayed:
>
> ...

> I've tried this code on several different makes of routers
> (different IOS
> versions) an on OS X and Windows XP, so I'm sure it must be
> something I'm
> doing wrong. That last cmd() also works with other IOS commands, so
> it's not
> something special with exit.
>
> I've been digging through the docs and google, and I've tried the
> different
> modes for telnets and I even spent some time experimenting with
> different
> values for prompt, but I don't think that's the issue.
>
> Obviously I can get the script to work, but I'm more curious as to
> why it's
> requiring that last command to be run. I'd appreciate any insight
> anyone can
> offer.

I haven't used Net::Telnet but my guess would be that it's a timing /
flushing problem. Have you tried putting delays (sleep(1)) between
commands?

Ben