On 4/1/07, Brian Candler <B.Candler / pobox.com> wrote: > On Sat, Mar 31, 2007 at 10:40:15PM +0900, Robert Dober wrote: > > >Not that I'm aware of. But if you discover something please let me know - > > >I'm going to have to do this myself in the next few weeks too. > > > > > >I was planning just to use plain Net::Telnet, which I think is good enough > > >for what I need. > > Please kindly let me know about this, I was trying to do this with > > Catalyst 29xx series Switches and a 2600 router, no luck so far, I > > guess the prompt, timeout selection is quite tricky :( > > The best documentation is the source, /usr/lib/ruby/1.8/net/telnet.rb > > Make sure you call your code with a debug block, e.g. (untested) > > n = Net::Telnet(...) > blk = proc { |str| $stderr << str } > n.login("user", "password", &blk) > n.cmd("show users", &blk) > > By adding &blk to all of the Net::Telnet methods, you'll get debugging > output to the screen and you can see how far it's getting. > > IIRC, the default regexp for a prompt looks for '# ' and '> ' (i.e. with a > trailing space). Typical Cisco prompt is 'router>' without the trailing > space. So easy enough to fix: just pass in a suitable prompt regexp. > > Brian. > Brian that is sound advice, but actually the problem is more or less the subtle details about the Cisco interface(1), like getting rid of the '---More---' or nonstandard login without user. I think that's why there are some modules around in other languages. I think it is a good possibility to share some findings and I might have a look at the Perl module some of these days. Cheers Robert > (1) used net/telnet for some remote control of old Unix systems without ssh quite often, the code is really easy to factorize, maybe it is too for Cisco, but given the complexity of the Cisco OS I doubt it :(, So the problem is not within Ruby but within Cisco. -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw