summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/clogin.in22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/clogin.in b/bin/clogin.in
index 99a0874..b7ac1a2 100644
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -296,7 +296,7 @@ proc source_password_file { password_file } {
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
global spawn_id in_proc do_command do_script platform
- global prompt u_prompt p_prompt e_prompt sshcmd
+ global prompt u_prompt p_prompt e_prompt sshcmd usercmd usercmd_chat
set in_proc 1
set uprompt_seen 0
@@ -327,6 +327,22 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send_user "\nError: $sshcmd failed: $reason\n"
return 1
}
+ } elseif [string match "usercmd" $prog] { # user supplies connect cmd
+ set retval [ catch {eval spawn $usercmd} reason ]
+ if { $retval } {
+ send_user "\nError: '$usercmd' failed: $reason\n"
+ exit 1
+ }
+ if { [llength $usercmd_chat] > 0 } {
+ #send_user "\nExecuting usercmd_chat: $usercmd_chat\n"
+ sleep 0.3
+ foreach {i j} $usercmd_chat {
+ expect {
+ -re $i { eval send "\"$j\""}
+ timeout { send "\r"; send_user "\nTimeout in usercmd_chat waiting for -re $i: punting with CR\n"; break }
+ }
+ }
+ }
} elseif ![string compare $prog "rsh"] {
global command
@@ -823,6 +839,10 @@ foreach router [lrange $argv $i end] {
set sshcmd [find sshcmd $router]
if { "$sshcmd" == "" } { set sshcmd {ssh} }
+ # If user provides a router-specific connection method, use it
+ set usercmd [find usercmd $router]
+ set usercmd_chat [find usercmd_chat $router]
+
# Login to the router
if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} {
# if login failed or rsh was unsuccessful, move on to the next device