From: William Ramirez Date: 2006-10-26T11:37:11+09:00 Subject: Net::Telnet Question ------=_Part_17580_21376303.1161830226694 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. Here's the code: require 'net/telnet' login_password = "password" enable_password = "password" host = "10.1.1.1" cisco_device = Net::Telnet::new("Host" => host, "Timeout" => 10, "Prompt" => /[\w+]*[>#]\z/, "Output_log" => 'output.log') cisco_device.puts(login_password) { |c| print c } #login cisco_device.cmd("terminal length 0") { |c| print c } #stops the more prompts cisco_device.cmd("enable") { |c| print c } #enter enable mode cisco_device.puts(enable_password) #configure ip access-group cisco_device.cmd("configure terminal") { |c| print c } cisco_device.cmd("interface Ethernet 0") { |c| print c } cisco_device.cmd("ip access-group 10 in") { |c| print c } #cisco_device.cmd("exit") { |c| print c } #-----Confusing Line----- cisco_device.close As the code is there, here's the ouput in both the output log and the screen. User Access Verification Password: Router>terminal length 0 Router>ena Password: Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface Ethernet 0 Router(config-if)# This also has the side effect of not producing the effect I desire (in this case the access list is not applied) 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: User Access Verification Password: Router>terminal length 0 Router>enable Password: Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface Ethernet 0 Router(config-if)#ip access-group 10 in Router(config-if)# 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. Thanks, William Ramirez ------=_Part_17580_21376303.1161830226694--