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 4431f63..05f75d9 100644
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -319,7 +319,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 command 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
@@ -350,6 +350,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"] {
if { ! $do_command } {
if { [llength $cmethod] == 1 } {
@@ -845,6 +861,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]} {
incr exitval