[rancid] [PATCH 2/2] Multiple fixes/improvements for Extreme XOS

john heasley heas at shrubbery.net
Tue Nov 29 22:51:46 UTC 2011


Mon, Nov 28, 2011 at 03:36:45PM +0200, Zenon Mousmoulas:
> Improve support for Extreme Networks devices running XOS:
> - The pager can be disabled per session since XOS 12.3, try to do that
>   in order to avoid struggling with pager prompts and ANSI sequences
>   altogether (clogin).

> +++ rancid-2.3.6-grnet/bin/clogin.in	2011-11-26 00:15:17.000000000 +0200
> @@ -610,11 +610,9 @@
>      global do_saveconfig in_proc platform
>      set in_proc 1
>  
> -    # If the prompt is (enable), then we are on a switch and the
> -    # command is "set length 0"; otherwise its "terminal length 0".
> -    # skip if its an extreme (since the pager can not be disabled on a
> -    # per-vty basis).
>      if { [ string compare "extreme" "$platform" ] } {
> +        # If the prompt is (enable), then we are on a switch and the
> +        # command is "set length 0"; otherwise its "terminal length 0".
>  	if [ regexp -- ".*> .*enable" "$prompt" ] {
>  	    send "set length 0\r"
>  	    # This is ugly, but reduces code duplication, allowing the
> @@ -631,7 +629,12 @@
>  	    -re "\[\n\r]+"	{ exp_continue }
>  	}
>      } else {
> +	send "disable clipaging\r"
>  	set reprompt $prompt
> +	expect {
> +	    -re $reprompt	{}
> +	    -re "\[\n\r]+"	{ exp_continue }
> +	}
>      }
>  
>      # this is the only way i see to get rid of more prompts in o/p..grrrrr
> @@ -640,11 +643,14 @@
>      set commands [split $command \;]
>      set num_commands [llength $commands]
>      # the pager can not be turned off on the PIX, so we have to look
> -    # for the "More" prompt.  the extreme is equally obnoxious, with a
> -    # global switch in the config.
> +    # for the "More" prompt.

i think this what you really want:

Index: bin/clogin.in
===================================================================
--- bin/clogin.in	(revision 2340)
+++ bin/clogin.in	(working copy)
@@ -633,8 +633,8 @@
     set commands [split $command \;]
     set num_commands [llength $commands]
     # the pager can not be turned off on the PIX, so we have to look
-    # for the "More" prompt.  the extreme is equally obnoxious, with a
-    # global switch in the config.
+    # for the "More" prompt.  the extreme is equally obnoxious in pre-12.3 XOS,
+    # with a global switch in the config.
     for {set i 0} {$i < $num_commands} { incr i} {
 	send -- "[subst -nocommands [lindex $commands $i]]\r"
 	expect {
@@ -897,20 +897,25 @@
 				}
     }
     if { $do_command || $do_script } {
-	# If the prompt is (enable), then we are on a switch and the
-	# command is "set length 0"; otherwise its "terminal length 0".
-	if [regexp -- ".*> .*enable" "$prompt"] {
-	    send "set length 0\r"
-	    expect -re $prompt  {}
-	    send "set width 132\r"
-	    expect -re $prompt	{}
-	    send "set logging session disable\r"
+	if { [ string compare "extreme" "$platform" ] } {
+	    # If the prompt is (enable), then we are on a switch and the
+	    # command is "set length 0"; otherwise its "terminal length 0".
+	    if [regexp -- ".*> .*enable" "$prompt"] {
+		send "set length 0\r"
+		expect -re $prompt  	{}
+		send "set width 132\r"
+		expect -re $prompt	{}
+		send "set logging session disable\r"
+	    } else {
+		send "terminal length 0\r"
+		expect -re $prompt  	{}
+		send "terminal width 132\r"
+	    }
+	    expect -re $prompt		{}
 	} else {
-	    send "terminal length 0\r"
-	    expect -re $prompt  {}
-	    send "terminal width 132\r"
+	    send "disable clipaging\r"
+	    expect -re $prompt		{}
 	}
-	expect -re $prompt	{}
     }
     if { $do_command } {
 	if {[run_commands $prompt $command]} {


> -	set u_prompt "(Username|Login|login|user name|User):"
> +	set u_prompt "(Username|Login|login|user name|User): *"

why is this necessary?  if there happen to be spaces after the prompt, it
should be possible to ignore them, send the input and allow the next expect
to eat the spaces, if they exist.

>      } else {
>  	set u_prompt [join [lindex $u_prompt 0] ""]
>      }
>      set p_prompt [find passprompt $router]
>      if { "$p_prompt" == "" } {
> -	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
> +	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+): *"
>      } else {
>  	set p_prompt [join [lindex $p_prompt 0] ""]
>      }
>      set e_prompt [find enableprompt $router]
>      if { "$e_prompt" == "" } {
> -	set e_prompt "\[Pp]assword:"
> +	set e_prompt "\[Pp]assword: *"
>      } else {
>  	set e_prompt [join [lindex $e_prompt 0] ""]
>      }


More information about the Rancid-discuss mailing list