diff options
Diffstat (limited to 'bin/flogin.in')
-rw-r--r-- | bin/flogin.in | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/bin/flogin.in b/bin/flogin.in index f15b1ec..483a06e 100644 --- a/bin/flogin.in +++ b/bin/flogin.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 @@ -442,20 +442,20 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 - send "$userpswd\r" + send -- "$userpswd\r" exp_continue } -re "$u_prompt" { - send "$user\r" + send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { - send "$userpswd\r" + send -- "$userpswd\r" } else { - send "$passwd\r" + send -- "$passwd\r" } exp_continue } @@ -480,8 +480,8 @@ proc do_enable { enauser enapasswd } { sleep 1; # dont go too fast for it now... 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"; @@ -507,27 +507,16 @@ proc run_commands { prompt command } { set in_proc 1 send "skip-page-display\r" - expect $prompt {} - - # Is this a multi-command? - if [ string match "*\;*" "$command" ] { - set commands [split $command \;] - set num_commands [llength $commands] - - for {set i 0} {$i < $num_commands} { incr i} { - send "[subst [lindex $commands $i]]\r" - expect { - -re "^\[^\n\r]*$prompt." { exp_continue } - -re "^\[^\n\r *]*$prompt" {} - -re "\[\n\r]" { exp_continue } - } - } - } else { - send "[subst $command]\r" + expect -re "$prompt" {} + + set commands [split $command \;] + set num_commands [llength $commands] + for {set i 0} {$i < $num_commands} { incr i} { + send -- "[subst [lindex $commands $i]]\r" expect { - -re "^\[^\n\r]*$prompt." { exp_continue } - -re "^\[^\n\r *]*$prompt" {} - -re "\[\n\r]" { exp_continue } + -re "^\[^\n\r]*$prompt." { exp_continue } + -re "^\[^\n\r *]*$prompt" {} + -re "\[\n\r]" { exp_continue } } } send "exit\r" @@ -671,6 +660,15 @@ foreach router [lrange $argv $i end] { } } } + # we are logged in, now figure out the full prompt + send "\r" + expect { + -re "\[\r\n]+" { exp_continue; } + -re "^.+$prompt" { set junk $expect_out(0,string); + regsub -all "\[\]\[ ]" $junk {\\&} prompt; + } + } + if { $do_command } { if {[run_commands $prompt $command]} { @@ -680,7 +678,7 @@ foreach router [lrange $argv $i end] { } elseif { $do_script } { # fucking foundry send "skip-page-display\r" - expect $prompt {} + expect -re $prompt {} source $sfile catch {close}; } else { |