I am having trouble getting into enable mode and running commands on a
cisco router using ssh. The following code allows me to successfully
login and run a command and display the output:
-----------------------------------
require "rubygems"
require "net/ssh"

Net::SSH.start( '10.1.1.1', 'jackster', :password => "my_password" ) do
|ssh_connection|

ssh_connection.open_channel do |channel|
 channel.on_data do |ch, data|
    puts data
end
channel.exec "sh arp" do |ch, success|

    if success
      puts "command has begun executing..."
    else
      puts "alas! the command could not be invoked!"
    end
end
end
ssh_connection.loop
end
-------------------------------
Here is my attempt at running the same command from after trying to get
into enable mode:

Net::SSH.start( '10.1.1.1', 'jackster', :password => "my_password" ) do
|ssh_connection|

ssh_connection.open_channel do |channel|
 channel.on_data do |ch, data|
    puts data
end
channel.exec "enable"
# I think I need something here to expect the "Password: " prompt before
sending
# the password?
channel.send_data("my_enable_password\n")
channel.exec "sh arp" do |ch, success|

    if success
      puts "command has begun executing..."
    else
      puts "alas! the command could not be invoked!"
    end
end
end
ssh_connection.loop
end
-------------------
The problem with this code is the script gets stuck on the "Password:"
prompt and waits for the enable password.

Any help getting past this would be appreciated.
thanks

Jackster
-- 
Posted via http://www.ruby-forum.com/.