J
jackster the jackle
Hi Ruby Forum,
I have some code that will login to my cisco router and run a basic
command.
The problem is, I need to get into enable mode to run additional
command. Getting into enable mode requires typing "enable", waiting for
the prompt "Password: " then entering another password.
This code works and gets me into the router but not in enable mode:
#!/usr/local/bin/ruby
require 'net/telnet'
CISCO = "172.31.1.1" #Enter the IP address here
USER = "jsmith" #Enter username here
PASS = "mypassword" #Enter password here
ENABLE = "myenablepass" #Enter enable password here
tn = Net::Telnet::new("Host" => CISCO,
"Timeout" => 5,
"Prompt" => /Username/ )
tn.cmd("\n#{USER}") { |c| print c }
tn.cmd(PASS) { |c| print c }
tn.cmd("sh mod\n") { |c| print c }
Instead of sending the command "sh mod\n" as shown above, I want to get
into enable mode and send the command "sh run\n".
The problem is, I get to the password prompt but the router is not
taking my password for some reason and I know the password is good.
Here is the added code that I'm having trouble with:
tn = Net::Telnet::new("Host" => CISCO,
"Timeout" => 5,
"Prompt" => /Username: / )
tn.cmd("\n#{USER}") { |c| print c }
tn.cmd(PASS) { |c| print c }
tn.cmd("enable\n") { |c| print c }
tn.waitfor(/Password: /)
tn.cmd(ENABLE) { |c| print c }
tn.cmd("sh run\n") { |c| print c }
Any ideas to get me into enable mode here would be greatly appreciated.
thanks
jackster
I have some code that will login to my cisco router and run a basic
command.
The problem is, I need to get into enable mode to run additional
command. Getting into enable mode requires typing "enable", waiting for
the prompt "Password: " then entering another password.
This code works and gets me into the router but not in enable mode:
#!/usr/local/bin/ruby
require 'net/telnet'
CISCO = "172.31.1.1" #Enter the IP address here
USER = "jsmith" #Enter username here
PASS = "mypassword" #Enter password here
ENABLE = "myenablepass" #Enter enable password here
tn = Net::Telnet::new("Host" => CISCO,
"Timeout" => 5,
"Prompt" => /Username/ )
tn.cmd("\n#{USER}") { |c| print c }
tn.cmd(PASS) { |c| print c }
tn.cmd("sh mod\n") { |c| print c }
Instead of sending the command "sh mod\n" as shown above, I want to get
into enable mode and send the command "sh run\n".
The problem is, I get to the password prompt but the router is not
taking my password for some reason and I know the password is good.
Here is the added code that I'm having trouble with:
tn = Net::Telnet::new("Host" => CISCO,
"Timeout" => 5,
"Prompt" => /Username: / )
tn.cmd("\n#{USER}") { |c| print c }
tn.cmd(PASS) { |c| print c }
tn.cmd("enable\n") { |c| print c }
tn.waitfor(/Password: /)
tn.cmd(ENABLE) { |c| print c }
tn.cmd("sh run\n") { |c| print c }
Any ideas to get me into enable mode here would be greatly appreciated.
thanks
jackster