[rancid] Re: hlogin chomps off portion of 'show config' using -c .

Mr. James W. Laferriere babydr at baby-dragons.com
Wed May 21 23:52:32 UTC 2008


 	Hello All ,

On Wed, 21 May 2008, Mr. James W. Laferriere wrote:
> 	Hello All ,  Can someone among you's point at where in hlogin may be 
> the culprit ?  My diagnostic skill(s) are faded today ,  insufficient sleep .
>
> # hlogin -c "show run" vh-sw01a > hlogin-chomp.log
>
> 	The chomp off is quite visiable .  Below is the part that is missing 
> .
> 	I don't see anything in the output that might cause this to happen .
> 	This is with the patch I sent earier today ,  I'll try it without as 
> well .

   An updated patch(attached) that (seems) to fix the chomp'ng .
 	Please review & Comment .

 		Tia ,  JimL
-- 
+------------------------------------------------------------------+
| James   W.   Laferriere | System    Techniques | Give me VMS     |
| Network&System Engineer | 2133    McCullam Ave |  Give me Linux  |
| babydr at baby-dragons.com | Fairbanks, AK. 99701 |   only  on  AXP |
+------------------------------------------------------------------+
-------------- next part --------------
--- /usr/local/rancid/bin/hlogin-v1_40-20061208	2008-05-15 17:00:00.000000000 -0800
+++ /usr/local/rancid/bin/hlogin	2008-05-21 15:49:26.000000000 -0800
@@ -473,13 +473,45 @@
     return 0
 }
 
+# Check (as best we can) if we are on a HP router or switch .
+# Actually checking if is a router & saying otherwise it's a switch .
+# & Set the pageR off variable .
+proc chk_rtr {in_proc prompt timeout} {
+  set old_Timeout $timeout
+  set timeout 5
+  global pageR
+  set Buffer "" 
+  log_user 0
+  exp_send "show version\r"
+  expect {
+    -re "Image stamp|Router" {
+      set Buffer $expect_out(0,string); 
+    }
+  }
+  log_user 1
+  if { $Buffer eq "Image stamp" } {
+    # I'm a SWITCH ...
+    set pageR "no page"
+  }
+  if { $Buffer eq "Router" } {
+    # I'm a ROUTER ...
+    set pageR "terminal length 0"
+  }
+  if { $Buffer eq "" } {
+    # Default to (hoping) I'm a ROUTER ... 
+    set pageR "terminal length 0"
+  }
+  set timeout $old_Timeout
+  return
+}
+
 # Run commands given on the command line.
-proc run_commands { prompt command } {
+  proc run_commands { prompt command pageR } {
     global in_proc platform
     set in_proc 1
-
+    
     # Turn off the pager and escape regex meta characters in the $prompt
-    send "terminal length 0\r"
+    send "$pageR\r"
     regsub -all "\[)(]" $prompt {\\&} reprompt
     expect {
 	-re $reprompt	{}
@@ -716,14 +748,16 @@
 	-re "\[\r\n]+"		{ exp_continue; }
 	-re "^.+$prompt"	{ set prompt $expect_out(0,string); }
     }
-
+    # check if we are on a route or not ,
+    # & Set pageR variable accordingly .
+    chk_rtr $in_proc $prompt $timeout
     if { $do_command } {
-	if {[run_commands $prompt $command]} {
+	if {[run_commands $prompt $command $pageR]} {
 	    continue
 	}
     } elseif { $do_script } {
 	# disable the pager
-	send "terminal length 0\r"
+        send "$pageR\r"
 	expect -re $prompt	{}
 	source $sfile
 	close


More information about the Rancid-discuss mailing list