[rancid] clogin can't login to more then one router.

heasley heas at shrubbery.net
Mon May 5 23:06:13 UTC 2014


Mon, May 05, 2014 at 07:40:06AM +0200, Per-Olof Olsson:
> 
> clogin only work if one router is listed at command line.
> (rancid 2.3.8 and 3.0 tested)
> 
> clogin -c "show term" router1 router2
> 
> output for second router:
> --------------------------
> can't read "autoenable": no such variable
>     while executing
> "if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
>         send_user -- "\nError: no enable password for $router in $password_file...."
>     ("foreach" body line 28)
>     invoked from within
> "foreach router [lrange $argv $i end] {
>     set router [string tolower $router]
>     # attempt at platform switching.
>     set platform ""
>     send_user ..."
>     (file "/usr/local/rancid/bin/clogin" line 759)
> ----------------------------
> 
> Possible more settings need to be reset before login to each router.
> Got it to work for my settings, by moving "set enable 0" inside foreach loop.
> 

I think you misread the error msg.  this seems like a better fix, and yet
still somewhat lacking, in the sense that autoenable should just go away,
eventually.  look good?

Index: bin/clogin.in
===================================================================
--- bin/clogin.in	(revision 2838)
+++ bin/clogin.in	(working copy)
@@ -750,7 +750,6 @@
 set in_proc 0
 set exitval 0
 set prompt_match ""
-set enable 0
 foreach router [lrange $argv $i end] {
     set router [string tolower $router]
     # attempt at platform switching.
@@ -769,9 +768,23 @@
 	set prompt "(>|#| \\(enable\\))"
     }
 
-    # look for noenable option in .cloginrc
-    if { [find noenable $router] == "1" } {
+    # look for autoenable option in .cloginrc & cmd-line
+    set ae [find autoenable $router]
+    if { "$ae" == "1" || $avautoenable } {
+	set autoenable 1
+    } else {
+	set autoenable 0
+    }
+    # look for enable options in .cloginrc & cmd-line
+    if { $avenable == 0 } {
 	set enable 0
+    } else {
+	set ne [find noenable $router]
+	if { "$ne" == "1" || "$autoenable" == "1" } {
+	    set enable 0
+	} else {
+	    set enable 1
+	}
     }
 
     # Figure out passwords
@@ -882,18 +895,6 @@
     # Figure out the prompt.
     if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } {
 	set enable 0
-    } else {
-	if { $avenable == 0 } {
-	    set enable 0
-	} else {
-	    set ne [find noenable $router]
-	    set ae [find autoenable $router]
-	    if { "$ne" == "1" || "$ae" == "1" || $avautoenable } {
-		set enable 0
-	    } else {
-		set enable 1
-	    }
-	}
     }
     if { $enable } {
 	if {[do_enable $enauser $enapasswd]} {



More information about the Rancid-discuss mailing list