oxidized icon indicating copy to clipboard operation
oxidized copied to clipboard

Allow configure mode in prompt regex

Open mrplow87 opened this issue 7 years ago • 6 comments

To properly use oxidized-script and switch to configure terminal, the prompt regex needs to accept <hostname>(config)# and all other context layers (vlan-... etc.).

With the given regex, oxidized-script times out once the context is switched to configure terminal because the regex does not match anymore.

mrplow87 avatar Sep 27 '17 09:09 mrplow87

"But wait, there's more". Some older firmwares of HP Procurve do not accept password username plaintext password which caused the prompt regex to fail when issuing password manager.

host(config)# password manager
New password for manager: ...
Please retype new password for manager: ...
host(config)# 

Basically ^\r?([\w .-]+: |([\w.-]+(([\w.-]+))*#) )$ would allow any prompt ending with : additionally to a proper prompt. But I'm not sure, if this is the way we want to go here.

mrplow87 avatar Sep 27 '17 09:09 mrplow87

Similar changes to allow configure terminal may apply to other hardware as well.

  • nos.rb -> ^(?:\e[..h)?[\w.-]+(([\w.-]+))*# $

mrplow87 avatar Sep 27 '17 12:09 mrplow87

@mrplow87 the block (config) you mentioned can repeat? if not you could replace the * for ? :neckbeard:

danilopopeye avatar Sep 27 '17 14:09 danilopopeye

Oh, that's my laziness and old habit to get zero occurances of that group matched. Will be replaced!

mrplow87 avatar Sep 27 '17 15:09 mrplow87

Definitely a legit problem. But I think we probably should have separate regexp for different state.

Possibly we should make prompt an instance of new prompts class. And for backward compatibility 'prompt = x' would be equivalent to 'prompt.exec = x'. Then we add 'prompt.config = y'.

But then the class probably should indicate WHEN should we expect each prompt.

I think this needs more thought. 7

ytti avatar Mar 17 '18 14:03 ytti

Please fix the conflict and add your change to CHANGELOG

mortzu avatar May 13 '22 19:05 mortzu