summaryrefslogtreecommitdiffstats
path: root/bin/elogin.in
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2001-08-03 03:13:25 +0000
committerTar Committer <tar@ocjtech.us>2001-08-03 03:13:25 +0000
commitaf496d2efa0969f29a22a4236c620f513eb90287 (patch)
treef3bc37d0d677b7ae1b58ae643fa25a91b80655aa /bin/elogin.in
parent0e84b727786a16ade28bb081742e5c39c33ed7fa (diff)
downloadrancid-af496d2efa0969f29a22a4236c620f513eb90287.tar.gz
rancid-af496d2efa0969f29a22a4236c620f513eb90287.tar.xz
rancid-af496d2efa0969f29a22a4236c620f513eb90287.zip
Imported from rancid-2.2b5.tar.gz.rancid-2.2b5
Diffstat (limited to 'bin/elogin.in')
-rwxr-xr-xbin/elogin.in24
1 files changed, 18 insertions, 6 deletions
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]