-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prompt not matched correctly #3
Comments
Hi, Could you turn on debug before login and send me the output? r = Ios.new Thanks |
Hi, The output with the debug is there : https://gist.github.com/gleonet/39b6f623f8687b5e7dde Thanks, Gael |
Hi, You are correct: removing '>' from the reggae will create its own set of issues. Thanks |
Hi Gael Could you check if de7020a Thx |
Hi Jean-Michel, I think to use expect4r in a web front-end which will be used to facilitate the configuration of our routers during the installation. Thanks for your help. Regards, Gael |
Should work: jmes-MacBook:test jme$ irb banner login ^CCisco Configuration Professional (Cisco CP) is installed on this device. YOU MUST USE CISCO CP or the CISCO IOS CLI TO CHANGE THESE Here are the Cisco IOS commands. username privilege 15 secret 0 Replace and with the username and password you want IF YOU DO NOT CHANGE THE PUBLICLY-KNOWN CREDENTIALS, YOU WILL For more information about Cisco CP please follow the instructions in the QUICK START GUIDE for your router or go to http://www.cisco.com/go/ciscocp^C Router# Gateway of last resort is not set
C 192.168.131.0/24 is directly connected, Ethernet0/0 |
Hi, Your fix solves my previous issue but the login command still failed with another error message but when I check with connected? or by running a command the login seems to be successful. Here is the log with the debug :on debug: buf0: [Q]
...
debug: buf0: [QUICK START GUIDE]
debug: matching PROMPT
debug: QUICK START GUIDE
debug: buf0: [U]
...
debug: buf0: [Username:]
debug: match USERNAME
debug: Username:
debug: print: "cisco\r", io_writer: #<File:0xb3fa524>
debug: buf0: [ ]
debug: buf0: [ \r]
debug: buf0: [ \r\n]
debug: match EOL
debug: match EOL
debug:
debug: buf0: [U]
...
debug: buf0: [Username:]
debug: match USERNAME
debug: Username:
debug: print: "cisco\r", io_writer: #<File:0xb3fa524>
debug: buf0: [ ]
debug: buf0: [ c]
debug: buf0: [ ci]
debug: buf0: [ cis]
debug: buf0: [ cisc]
debug: buf0: [ cisco]
debug: buf0: [ cisco\r]
debug: buf0: [ cisco\r\n]
debug: match EOL
debug: match EOL
debug: cisco
debug: buf0: [P]
...
debug: buf0: [Password:]
debug: match PASSWORD
debug: Password:
debug: buf0: [ ]
debug: buf0: [ C]
debug: buf0: [ C\r]
debug: buf0: [ C\r\n]
debug: match EOL
debug: match EOL
...
debug: buf0: [8]
debug: buf0: [86]
debug: buf0: [867]
debug: buf0: [867#]
debug: IO.select is NIL (TIMEOUT=2)
debug: IO.select is NIL (TIMEOUT=13)
debug: readbuf: _io_exit?Expect4r::ConnectionError: Expect4r::ConnectionError
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/expect/io.rb:339:in `_login'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/router/cisco/ios/ios.rb:45:in `login'
from (irb):6
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>' |
Hi, I noticed that for every match you have two debug statements ? debug: buf0: [ cisco\r\n] debug: buf0: [8] as well as two IO.select .... debug: IO.select is NIL (TIMEOUT=2) Also ps1 prompt should match "867#" I would need access to this box to understand what's happening. Thanks |
Sorry, it will not be possible to give you an access on the router. I rebuild the gem based on your last commit and I don't have exactly the same output for the debug than my previous comment. I'm not sure if I correctly built the gem but I still have the issue with the wrongly match. I think the double match for EOL is due to the double characters \r \n at the end of each lines. Here is a sample of the debug lines with my last test. debug: buf0: [u]
...
debug: buf0: [username <myuser>]
debug: match PROMPT
debug: username <myuser>
debug: print: "enable\r", io_writer: #<File:0x0000000178eb40>
...
Username:
Username: enable
Password:
debug: print: "term len 0\r", io_writer: #<File:0x0000000178eb40>
debug: buf0: [\r]
debug: buf0: [\r\n]
debug: matching EOL
...
debug: buf0: [U]
...
debug: buf0: [Username: ]
debug: IO.select is NIL (TIMEOUT=13)
debug:
debug: Username: Expect4r::ExpTimeoutError: Expect4r::ExpTimeoutError
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/expect/io.rb:396:in `putline'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/router/cisco/ios/ios.rb:50:in `putline'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/expect/io.rb:180:in `block in exp_send'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/expect/io.rb:178:in `each_line'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/expect/io.rb:178:in `exp_send'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/router/cisco/ios/modes.rb:41:in `exec'
from /usr/lib/ruby/gems/1.9.1/gems/expect4r-0.0.9/lib/router/cisco/ios/ios.rb:40:in `login'
from (irb):10
from /usr/bin/irb:12:in `<main>' Thanks for your help. Gael Leonet |
Could you please attach to an email to [email protected] Thanks |
Hi,
First of all I want to thank you for your library. It will be very useful for me.
I have an issue when I try to connect to a new router which has the default banner.
Expect4r matches one of the line in the banner and tries to send the login and the password before the real login prompt is ready.
The gist with the content of this banner : https://gist.github.com/gleonet/dc21a1316241474b9fae
I modified the file lib/router/cisco/ios/ios.rb at the line 16 from @PS1 = /(.)(>|#|$)\s$/ to @PS1 = /(.)(#|$)\s$/ and after that the login is successful but I suppose the character '>' is useful in other situation and my fix is not the good solution.
I hope this feedback could be useful for you.
Regards,
Gael Leonet
The text was updated successfully, but these errors were encountered: