From 09f0f026fd4931b90016d0090778983da01c294a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Dec 2008 03:43:51 +0000 Subject: Imported from rancid-2.3.2a9.tar.gz. --- bin/hlogin.in | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'bin/hlogin.in') diff --git a/bin/hlogin.in b/bin/hlogin.in index 1a7722c..e372fe0 100644 --- a/bin/hlogin.in +++ b/bin/hlogin.in @@ -3,7 +3,7 @@ ## $Id$ ## ## @PACKAGE@ @VERSION@ -## Copyright (c) 1997-2007 by Terrapin Communications, Inc. +## Copyright (c) 1997-2008 by Terrapin Communications, Inc. ## All rights reserved. ## ## This code is derived from software contributed to and maintained by @@ -79,7 +79,7 @@ set do_enapasswd 1 # attempt at platform switching. set platform "" # -set send_human {.4 .4 .7 .3 5} +set send_human {.2 .1 .4 .2 1} # Find the user in the ENV, or use the unix userid. if {[ info exists env(CISCO_USER) ]} { @@ -426,13 +426,13 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { catch {close}; catch {wait}; send_user "\nError: Unknown host\n"; wait; return 1 } - -re "$u_prompt" { send "$user\r" + -re "$u_prompt" { send -- "$user\r" expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Login invalid" { send_user "\nError: Invalid login\n"; catch {close}; catch {wait}; return 1 } - -re "$p_prompt" { send "$userpswd\r" } + -re "$p_prompt" { send -- "$userpswd\r" } "$prompt" { set in_proc 0; return 0 } "Press any key to continue" { send " " @@ -443,9 +443,9 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { } -re "$p_prompt" { if ![string compare $prog "ssh"] { - send "$userpswd\r" + send -- "$userpswd\r" } else { - send "$passwd\r" + send -- "$passwd\r" } expect { eof { send_user "\nError: Couldn't login\n"; @@ -456,7 +456,7 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send " "; exp_continue } - -re "$e_prompt" { send "$enapasswd\r" } + -re "$e_prompt" { send -- "$enapasswd\r" } "$prompt" { set in_proc 0; return 0 } @@ -483,8 +483,8 @@ proc do_enable { enauser enapasswd } { send "enable\r" expect { - -re "$u_prompt" { send "$enauser\r"; exp_continue} - -re "$e_prompt" { send "$enapasswd\r"; exp_continue} + -re "$u_prompt" { send -- "$enauser\r"; exp_continue} + -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> (enable) " } denied { send_user "\nError: Check your Enable passwd\n"; return 1} @@ -513,40 +513,43 @@ proc run_commands { prompt command } { } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 - # Is this a multi-command? + set commands [split $command \;] set num_commands [llength $commands] # if the pager can not be turned off, we have to look for the "More" # prompt. for {set i 0} {$i < $num_commands} { incr i} { - send "[subst -nocommands [lindex $commands $i]]\r" + send -- "[subst -nocommands [lindex $commands $i]]\r" expect { - -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } - -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" + -re "^\[^\n\r *]*$reprompt" { catch {send_user -- "$expect_out(buffer)"} } + -re "^\[^\n\r]*$reprompt." { catch {send_user -- "$expect_out(buffer)"} exp_continue } - -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" + -re "\[\n\r]+" { catch {send_user -- "$expect_out(buffer)"} exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " expect { # gag, 2 more prompts -re "\[\r\n]*\r" {} - -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " "; exp_continue } + -re "\[^\r\n]*Press to cont\[^\r\n]*" { + catch {send " "}; + exp_continue + } } exp_continue } - -re "^<-+ More -+>\[^\n\r]*" { send " " + -re "^<-+ More -+>\[^\n\r]*" { catch {send " "} exp_continue } - -re "^-+ MORE -+\[^\n\r]*" { send " " + -re "^-+ MORE -+\[^\n\r]*" { catch {send " "} exp_continue } # 3 flavours of the more prompt, first -More-, then --More-- (for # cisco/riverhead AGM), then with more dashes. - -re "^-More-\[^\n\r-]*" { send " " + -re "^-More-\[^\n\r-]*" { catch {send " "} exp_continue } - -re "^--More--\[^\n\r-]*" { send " " + -re "^--More--\[^\n\r-]*" { catch {send " "} exp_continue } -re "^---+More---+\[^\n\r]*" { - send " " + catch {send " "} exp_continue } -re "\b+" { exp_continue } } @@ -555,20 +558,20 @@ proc run_commands { prompt command } { send -h "exit\r" expect { "Do you want to save current configuration" { - send "n\r" + catch {send "n\r"} exp_continue } "Do you wish to save " { - send "n\r" + catch {send "n\r"} exp_continue } "Do you want to log out" { - send "y\r" + catch {send "y\r"} exp_continue } -re "\[\r\n]+" { exp_continue } -re "^.+>" { - send -h "exit\r" + catch {send -h "exit\r"} exp_continue } timeout { catch {close}; catch {wait}; -- cgit