From b73f299e731fbddae095c0b5eff04717b6dce1af Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 20:34:57 +0000 Subject: Imported from rancid-2.3.2a8.tar.gz. --- bin/rivlogin.in | 71 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 21 deletions(-) (limited to 'bin/rivlogin.in') diff --git a/bin/rivlogin.in b/bin/rivlogin.in index 2d80217..7a65986 100644 --- a/bin/rivlogin.in +++ b/bin/rivlogin.in @@ -1,26 +1,46 @@ #! @EXPECT_PATH@ -- ## -## $Id: rivlogin.in,v 1.26 2006/12/08 21:28:26 heas Exp $ +## $Id$ ## ## @PACKAGE@ @VERSION@ -## Copyright (C) 1997-2006 by Terrapin Communications, Inc. +## Copyright (c) 1997-2007 by Terrapin Communications, Inc. ## All rights reserved. ## -## This software may be freely copied, modified and redistributed -## without fee for non-commerical purposes provided that this license -## remains intact and unmodified with any RANCID distribution. +## This code is derived from software contributed to and maintained by +## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan, +## Pete Whiting, Austin Schutz, and Andrew Fort. ## -## There is no warranty or other guarantee of fitness of this software. -## It is provided solely "as is". The author(s) disclaim(s) all -## responsibility and liability with respect to this software's usage -## or its effect upon hardware, computer systems, other software, or -## anything else. -## -## Except where noted otherwise, rancid was written by and is maintained by -## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## 1. Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## 2. Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## 3. All advertising materials mentioning features or use of this software +## must display the following acknowledgement: +## This product includes software developed by Terrapin Communications, +## Inc. and its contributors for RANCID. +## 4. Neither the name of Terrapin Communications, Inc. nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## 5. It is requested that non-binding fixes and modifications be contributed +## back to Terrapin Communications, Inc. ## +## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS +## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS +## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +## POSSIBILITY OF SUCH DAMAGE. # -# The login expect scripts were based on Erik Sherk's gwtn, by permission. +# The expect login scripts were based on Erik Sherk's gwtn, by permission. # # rivlogin - Riverstone (and Enterasys SSR) login # @@ -32,7 +52,7 @@ # Returned to the RANCID crowd by andrew fort # Usage line -set usage "Error: Usage: $argv0 \[-noenable\] \ +set usage "Error: Usage: $argv0 \[-dV\] \[-noenable\] \ \[-f cloginrc-file\] \[-c command\] \[-Evar=x\] \[-s script-file\] \ \[-x command-file\] \[-t timeout\] \[-o output-file\] \ router \[router...\]\n" @@ -781,7 +801,6 @@ for {set idx 0} {$idx < $argc} {incr idx} { set arg [lindex $argv $idx] switch -glob -- $arg { - -c* - -C* { if {! [ regexp .\[cC\](.+) $arg ignore command]} { @@ -789,6 +808,9 @@ for {set idx 0} {$idx < $argc} {incr idx} { set command [ lindex $argv $idx ] } set do_command 1 + # Expect debug mode + } -d* { + exp_internal 1 # Environment variable to pass to -s scripts } -E* { @@ -877,8 +899,10 @@ if { $idx == $argc } { } # main loop +set exitval 0 foreach router [lrange $argv $idx end] { -set router [string tolower $router] + set router [string tolower $router] + send_user -- "$router\n" # Figure out passwords if {$verbose == 1} { @@ -940,6 +964,7 @@ set router [string tolower $router] # Login to the router, set my_prompt to router's cmd prompt if {[login $router $user $userpswd $passwd $enapasswd ]} { + incr exitval if { $verbose == 1 } { puts "DEBUG: login to $router failed\n" } @@ -952,6 +977,7 @@ set router [string tolower $router] if { $enable == 1 } { if { [do_enable $enauser $enapasswd $userpswd] == 1} { + incr exitval if { $verbose == 1 } { puts "DEBUG: switch to enable mode on $router failed\n" } @@ -969,7 +995,8 @@ set router [string tolower $router] } if {[ run_commands $my_prompt $command ]} { - log_file + incr exitval + log_file exit 1 } else { logout $my_prompt @@ -1010,7 +1037,9 @@ set router [string tolower $router] log_file strip_log $output_file $router } -} -# puts "\n" -exit 0 + # End of for each router + catch {wait}; + sleep 0.3 +} +exit $exitval -- cgit