From af496d2efa0969f29a22a4236c620f513eb90287 Mon Sep 17 00:00:00 2001 From: Tar Committer Date: Fri, 3 Aug 2001 03:13:25 +0000 Subject: Imported from rancid-2.2b5.tar.gz. --- bin/flogin.in | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'bin/flogin.in') diff --git a/bin/flogin.in b/bin/flogin.in index ac60bf3..85f77d6 100755 --- a/bin/flogin.in +++ b/bin/flogin.in @@ -1,7 +1,7 @@ #!@EXPECT_PATH@ -- ## ## -## Copyright (C) 1997 by Henry Kilmer, Erik Sherk and Pete Whiting. +## Copyright (C) 1997-2001 by Henry Kilmer, Erik Sherk and Pete Whiting. ## All rights reserved. ## ## This software may be freely copied, modified and redistributed without @@ -30,10 +30,11 @@ # # Usage line -set usage "Usage: $argv0 \[-u user\] \[-p user-password\] \[-v vty-password\] \ -\[-w enable-username\] \[-e enable-password\] \[-noenable\] \ -\[-f cloginrc-file\] \[-y ssh_cypher_type\] \[-c command\] \[-s script-file\] \ -\[-autoenable\] \[-t timeout\] router \[router...\]\n" +set usage "Usage: $argv0 \[-autoenable\] \[-noenable\] \ +\[-c command\] \[-Evar=x\] \[-e enable-password\] \[-p user-password\] \ +\[-f cloginrc-file\] \[-s script-file\] \[-t timeout\] \[-u user\] \ +\[-v vty-password\] \[-w enable-username\]\[-y ssh_cypher_type\] \ +router \[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name @@ -106,9 +107,18 @@ for {set i 0} {$i < $argc} {incr i} { incr i set enausername [ lindex $argv $i ] } + # Environment variable to pass to -s scripts + } -E* + { + if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { + set E$varname $varvalue + } else { + send_user "Error: invalid format for -E in $arg\n" + exit 1 + } # Enable Password - } -e* - - -E* { + } -e* + { if {! [ regexp .\[eE\](.+) $arg ignore enapasswd]} { incr i set enapasswd [ lindex $argv $i ] @@ -158,7 +168,10 @@ for {set i 0} {$i < $argc} {incr i} { incr i set cmd_file [ lindex $argv $i ] } - set cmd_fd [open $cmd_file r] + if [ catch {set cmd_fd [open $cmd_file r]} reason ] { + send_user "\nError: $reason\n" + exit 1 + } set cmd_text [read $cmd_fd] close $cmd_fd set command [join [split $cmd_text \n] \;] @@ -464,11 +477,11 @@ foreach router [lrange $argv $i end] { if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { - send_user "Error - no password for $router in $password_file.\n" + send_user "Error: no password for $router in $password_file.\n" continue } - if { $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { - send_user "Error - no enable password for $router in $password_file.\n" + if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { + send_user "Error: no enable password for $router in $password_file.\n" continue } set passwd [lindex $pswd 0] -- cgit