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/elogin.in | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'bin/elogin.in') diff --git a/bin/elogin.in b/bin/elogin.in index 46f459d..1affce7 100755 --- a/bin/elogin.in +++ b/bin/elogin.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 @@ -23,7 +23,7 @@ # Usage line set usage "Usage: $argv0 \[-noenable\] \[-c command\] \ -\[-f cloginrc-file\] \[-p user-password\] \ +\[-Evar=x\] \[-f cloginrc-file\] \[-p user-password\] \ \[-s script-file\] \[-t timeout\] \[-u username\] \ \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ \[-y ssh_cypher_type\] router \[router...\]\n" @@ -95,9 +95,18 @@ for {set i 0} {$i < $argc} {incr i} { } -w* - -W* { # ignore -w + # 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* + { # ignore -e # Command to run. } -c* - @@ -147,7 +156,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] \;] @@ -398,7 +410,7 @@ foreach router [lrange $argv $i end] { if { $do_passwd } { 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 } set passwd [lindex $pswd 0] -- cgit