Ghislain Mary [mailto:nospam / lunacymaze.org] said:

#Here is what I did to access some information on a Cisco Access Point 
#using telnet:

[skipped useful/c-oo-l code/sample]

Hi Ghislain.

Thanks for the very helpful code. I will put it in my archive. I hope you
don't mind.

After scrutinizing your code, I got an important hint. I think i screwed up
my prompt option. The prompt works great in linux, but i failed to modify it
on other devices... My script seems to work now.. hopefully on all..

sample script and run:

--------------

>cat t.rb

time_start = Time::new

require 'net/telnet'
host = "10.1.1.1"
tn = Net::Telnet::new( \
           "Host"       => host,         # default: "localhost"
           "Port"       => 23,           # default: 23
           "Binmode"    => false,        # default: false
           "Output_log" => "output_log", # default: nil (no output)
           "Dump_log"   => "dump_log",   # default: nil (no output)
           "Prompt"     => /[$%#>]/,     # default: /[$%#>] \z/n
           "Telnetmode" => true,         # default: true
           "Timeout"    => 5,            # default: 10
           "Waittime"   => 0             # default: 0
)
tn.waitfor(/assword:/) {|c| print c}
tn.puts "testpassword"
tn.cmd("show version") { |c| print c }
tn.cmd("quit") {|c| print c}
tn.close

puts
puts "#{Time.now - time_start} seconds"

>t


User Access Verification

Password:
dev01>show version
Cisco Internetwork Operating System Software
IOS (tm) 1600 Software (C1600-Y-M), Version 12.0(9), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2000 by cisco Systems, Inc.
Compiled Tue 25-Jan-00 00:11 by bettyl
Image text-base: 0x02005000, data-base: 0x0246E5D8

ROM: System Bootstrap, Version 12.0(3)T, RELEASE SOFTWARE (fc1)
ROM: 1600 Software (C1600-RBOOT-R), Version 12.0(3)T,  RELEASE SOFTWARE
(fc1)

dev01 uptime is 1 day, 11 hours, 14 minutes
System restarted by power-on
System image file is "flash:c1600-y-mz.120-9"

cisco 1601 (68360) processor (revision C) with 7680K/512K bytes of memory.
Processor board ID 23082938, with hardware revision 00000003
Bridging software.
X.25 software, Version 3.0.0.
1 Ethernet/IEEE 802.3 interface(s)
1 Serial(sync/async) network interface(s)
System/IO memory with parity disabled
8192K bytes of DRAM onboard
System running from RAM
7K bytes of non-volatile configuration memory.

dev01>
0.531 seconds
----------------

works great!

Thanks again Ghislain.

kind regards -botp