summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2001-04-09 07:32:33 +0000
committerTar Committer <tar@ocjtech.us>2001-04-09 07:32:33 +0000
commit0e84b727786a16ade28bb081742e5c39c33ed7fa (patch)
tree12ee1a75666c0af32ecc7fbdc05c3a5833fb6fb8 /bin
parentb88919bea4b222a616adbdd2b82fc262a14afc8d (diff)
downloadrancid-0e84b727786a16ade28bb081742e5c39c33ed7fa.tar.gz
rancid-0e84b727786a16ade28bb081742e5c39c33ed7fa.tar.xz
rancid-0e84b727786a16ade28bb081742e5c39c33ed7fa.zip
Imported from rancid-2.2b.tar.gz.rancid-2.2b
Diffstat (limited to 'bin')
-rwxr-xr-xbin/alogin.in488
-rwxr-xr-xbin/arancid.in281
-rwxr-xr-xbin/cat5rancid.in3
-rwxr-xr-xbin/clogin.in50
-rwxr-xr-xbin/control_rancid.in4
-rwxr-xr-xbin/elogin.in38
-rwxr-xr-xbin/erancid.in3
-rwxr-xr-xbin/flogin.in42
-rwxr-xr-xbin/francid.in3
-rwxr-xr-xbin/jlogin.in46
-rwxr-xr-xbin/jrancid.in5
-rwxr-xr-xbin/rancid-fe.in2
-rwxr-xr-xbin/rancid.in9
-rwxr-xr-xbin/rrancid.in3
14 files changed, 872 insertions, 105 deletions
diff --git a/bin/alogin.in b/bin/alogin.in
new file mode 100755
index 0000000..fe55787
--- /dev/null
+++ b/bin/alogin.in
@@ -0,0 +1,488 @@
+#!@EXPECT_PATH@ --
+##
+##
+## Copyright (C) 1997 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# alogin - Alteon WebOS switch login
+#
+# afort@choqolat.org is responsible for this particular mess
+# (andrew fort)
+#
+
+# Usage line
+set usage "Usage: $argv0 \[-c command\]\
+\[-f cloginrc-file\]\
+\[-s script-file\] \[-t timeout\] \[-u username\]\
+\[-v vty-password\] \[-x command-file\]\
+\[-y ssh_cypher_type\] router \[router...\]\n"
+
+# env(CLOGIN) may contain:
+# x == do not set xterm banner or name
+
+# Password file
+set password_file $env(HOME)/.cloginrc
+# Default is to login to the router
+set do_command 0
+set do_script 0
+# The default is to automatically enable
+set enable 1
+# The default is that you login non-enabled (tacacs can have you login already enabled)
+set autoenable 0
+# The default is to look in the password file to find the passwords. This
+# tracks if we receive them on the command line.
+set do_passwd 1
+
+# Find the user in the ENV, or use the unix userid.
+if {[ info exists env(CISCO_USER) ] } {
+ set default_user $env(CISCO_USER)
+} elseif {[ info exists env(USER) ]} {
+ set default_user $env(USER)
+} else {
+ # This uses "id" which I think is portable. At least it has existed
+ # (without options) on all machines/OSes I've been on recently -
+ # unlike whoami or id -nu.
+ if [ catch {exec id} reason ] {
+ send_error "Error: could not exec id: $reason\n"
+ exit 1
+ }
+ regexp {\(([^)]*)} "$reason" junk default_user
+}
+
+# Sometimes routers take awhile to answer (the default is 10 sec)
+set timeout 45
+
+# Process the command line
+for {set i 0} {$i < $argc} {incr i} {
+ set arg [lindex $argv $i]
+
+ switch -glob -- $arg {
+ # Username
+ -u* -
+ -U* {
+ if {! [ regexp .\[uU\](.+) $arg ignore user]} {
+ incr i
+ set username [ lindex $argv $i ]
+ }
+ # VTY Password
+ } -v* -
+ -v* {
+ if {! [ regexp .\[vV\](.+) $arg ignore passwd]} {
+ incr i
+ set passwd [ lindex $argv $i ]
+ }
+ set do_passwd 0
+ # Enable Username
+ } -w* -
+ -W* {
+ # ignore -w
+ # Enable Password
+ } -e* -
+ -E* {
+ # ignore -e
+ # Command to run.
+ } -c* -
+ -C* {
+ if {! [ regexp .\[cC\](.+) $arg ignore command]} {
+ incr i
+ set command [ lindex $argv $i ]
+ }
+ set do_command 1
+ # Expect script to run.
+ } -s* -
+ -S* {
+ if {! [ regexp .\[sS\](.+) $arg ignore sfile]} {
+ incr i
+ set sfile [ lindex $argv $i ]
+ }
+ if { ! [ file readable $sfile ] } {
+ send_user "Error: Can't read $sfile\n"
+ exit 1
+ }
+ set do_script 1
+ # 'ssh -c' cypher type
+ } -y* -
+ -Y* {
+ if {! [ regexp .\[eE\](.+) $arg ignore cypher]} {
+ incr i
+ set cypher [ lindex $argv $i ]
+ }
+ # alternate cloginrc file
+ } -f* -
+ -F* {
+ if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
+ incr i
+ set password_file [ lindex $argv $i ]
+ }
+ # Timeout
+ } -t* -
+ -T* {
+ if {! [ regexp .\[tT\](.+) $arg ignore timeout]} {
+ incr i
+ set timeout [ lindex $argv $i ]
+ }
+ # Command file
+ } -x* -
+ -X {
+ if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} {
+ incr i
+ set cmd_file [ lindex $argv $i ]
+ }
+ set cmd_fd [open $cmd_file r]
+ set cmd_text [read $cmd_fd]
+ close $cmd_fd
+ set command [join [split $cmd_text \n] \;]
+ set do_command 1
+ # Do we enable?
+ } -noenable {
+ # ignore -noenable
+ # Does tacacs automatically enable us?
+ } -autoenable {
+ # ignore -autoenable
+ } -* {
+ send_user "Error: Unknown argument! $arg\n"
+ send_user $usage
+ exit 1
+ } default {
+ break
+ }
+ }
+}
+# Process routers...no routers listed is an error.
+if { $i == $argc } {
+ send_user "Error: $usage"
+}
+
+# Only be quiet if we are running a script (it can log its output
+# on its own)
+if { $do_script } {
+ log_user 0
+} else {
+ log_user 1
+}
+
+#
+# Done configuration/variable setting. Now run with it...
+#
+
+# Sets Xterm title if interactive...if its an xterm and the user cares
+proc label { host } {
+ global env
+ # if CLOGIN has an 'x' in it, don't set the xterm name/banner
+ if [info exists env(CLOGIN)] {
+ if {[string first "x" $env(CLOGIN)] != -1} { return }
+ }
+ # take host from ENV(TERM)
+ if [info exists env(TERM)] {
+ if [regexp \^(xterm|vs) $env(TERM) ignore ] {
+ send_user "\033]1;[lindex [split $host "."] 0]\a"
+ send_user "\033]2;$host\a"
+ }
+ }
+}
+
+# This is a helper function to make the password file easier to
+# maintain. Using this the password file has the form:
+# add password sl* pete cow
+# add password at* steve
+# add password * hanky-pie
+proc add {var args} { global int_$var ; lappend int_$var $args}
+proc include {args} {
+ global env
+ regsub -all "(^{|}$)" $args {} args
+ if { [ regexp "^/" $args ignore ] == 0 } {
+ set args $env(HOME)/$args
+ }
+ source_password_file $args
+}
+
+proc find {var router} {
+ upvar int_$var list
+ if { [info exists list] } {
+ foreach line $list {
+ if { [string match [lindex $line 0] $router ] } {
+ return [lrange $line 1 end]
+ }
+ }
+ }
+ return {}
+}
+
+
+# Loads the password file. Note that as this file is tcl, and that
+# it is sourced, the user better know what to put in there, as it
+# could install more than just password info... I will assume however,
+# that a "bad guy" could just as easy put such code in the clogin
+# script, so I will leave .cloginrc as just an extention of that script
+proc source_password_file { password_file } {
+ global env
+ if { ! [file exists $password_file] } {
+ send_user "Error: password file ($password_file) does not exist\n"
+ exit 1
+ }
+ file stat $password_file fileinfo
+ if { [expr ($fileinfo(mode) & 007)] != 0000 } {
+ send_user "Error: $password_file must not be world readable/writable\n"
+ exit 1
+ }
+ if [ catch {source $password_file} reason ] {
+ send_user "Error: $reason\n"
+ exit 1
+ }
+}
+
+
+# Log into the router.
+proc login { router user userpswd passwd prompt cmethod cyphertype } {
+ global spawn_id in_proc do_command do_script
+ global u_prompt p_prompt
+ set in_proc 1
+ set tryssh 1
+
+ # try each of the connection methods in $cmethod until one is successful
+ set progs [llength $cmethod]
+ foreach prog [lrange $cmethod 0 end] {
+ if ![string compare $prog "telnet"] {
+ if [ catch {spawn telnet $router} reason ] {
+ send_user "Error: telnet failed: $reason\n"
+ exit 1
+ }
+ } elseif ![string compare $prog "ssh"] {
+ if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
+ send_user "Error: ssh failed: $reason\n"
+ exit 1
+ }
+ } elseif ![string compare $prog "rsh"] {
+ if [ catch {spawn rsh -l $user $router} reason ] {
+ send_user "Error: rsh failed: $reason\n"
+ exit 1
+ }
+ } else {
+ puts "ERROR: unknown connection method: $prog"
+ return 1
+ }
+ incr progs -1
+ sleep 0.3
+
+ # This helps cleanup each expect clause.
+ expect_after {
+ timeout {
+ send_user "\nError: TIMEOUT reached\n"
+ catch {close}; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ } eof {
+ send_user "\nError: EOF received\n"
+ catch {close}; wait
+ if { $in_proc} {
+ return 1
+ } else {
+ continue
+ }
+ }
+ }
+
+ expect {
+ "Connection refused" {
+ close; wait
+ sleep 0.3
+ expect eof
+ send_user "Error: Connection Refused\n"; wait; return 1
+ } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } "Unknown host\r\n" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ } "Host is unreachable" {
+ expect eof
+ send_user "Error: Host Unreachable!\n"; wait; return 1
+ } "No address associated with name" {
+ expect eof
+ send_user "Error: Unknown host\n"; wait; return 1
+ }
+ -re "$u_prompt" { send "$user\r"
+ expect {
+ "Login incorrect" { send_user "Error: Couldn't login\n";
+ catch {close}; wait; return 1 }
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ -re "$p_prompt" { send "$userpswd\r" }
+ "$prompt" { set in_proc 0; return 0 }
+ }
+ exp_continue
+ }
+ -re "$p_prompt" { send "$passwd\r"
+ expect {
+ "Password incorrect" { send_user "Error: Couldn't login\n";
+ catch {close}; wait; return 1 }
+ eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ "$prompt" { set in_proc 0; return 0 }
+ "Confirm seeing above note" { send "y\r" }
+ }
+ exp_continue
+ }
+ -re "^Confirm seeing above note" { send "y\r" }
+ "Password incorrect" { send_user "Error: Check your password for $router\n";
+ catch {close}; wait; return 1 }
+ "$prompt" { }
+ denied { send_user "Error: Check your passwd for $router\n"
+ if { $do_command || $do_script } {
+ send "exit\r"
+ wait
+ return 1
+ } else {
+ return 1
+ }
+ }
+ "\r\n" { exp_continue; }
+ }
+ set in_proc 0
+ return 0
+}
+}
+
+# Run commands given on the command line.
+proc run_commands { prompt command } {
+ global in_proc
+ set in_proc 1
+
+ send "lines 0\r"
+ expect $prompt {}
+
+ regsub -all "\[)(]" $prompt {\\&} reprompt
+
+ # Is this a multi-command?
+ if [ string match "*\;*" "$command" ] {
+ set commands [split $command \;]
+ set num_commands [llength $commands]
+
+ for {set i 0} {$i < $num_commands} { incr i} {
+ send "[subst -nocommands [lindex $commands $i]]\r"
+ expect {
+ -re "^\[^\n\r]*$reprompt." {}
+ -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue }
+ -re "\[\n\r]" { exp_continue }
+ }
+ }
+ } else {
+ send "[subst -nocommands $command]\r"
+ expect {
+ -re "^\[^\n\r]*$reprompt." {}
+ -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue }
+ -re "\[\n\r]" { exp_continue }
+ }
+ }
+ send "exit\r"
+ expect {
+ -re "^WARNING: There are unsaved configuration changes."
+ {
+ send "y\r"
+ exp_continue
+ }
+ "\n" { exp_continue }
+ "\[^\n\r *]*Session terminated" { return 0 }
+ timeout { return 0 }
+ eof { return 0 }
+ }
+ set in_proc 0
+}
+
+#
+# For each router... (this is main loop)
+#
+source_password_file $password_file
+set in_proc 0
+foreach router [lrange $argv $i end] {
+ set router [string tolower $router]
+ send_user "$router\n"
+
+ # Figure out prompt.
+ set prompt "#"
+ set autoenable 1
+ set enable 0
+
+ # Figure out passwords
+ if { $do_passwd } {
+ set pswd [find password $router]
+ if { [llength $pswd] == 0 } {
+ send_user "Error - no password for $router in $password_file.\n"
+ continue
+ }
+ set passwd [lindex $pswd 0]
+ }
+
+ # Figure out username
+ if {[info exists username]} {
+ # command line username
+ set ruser $username
+ } else {
+ set ruser [find user $router]
+ if { "$ruser" == "" } { set ruser $default_user }
+ }
+
+ # Figure out username's password (if different from the vty password)
+ if {[info exists userpasswd]} {
+ # command line username
+ set userpswd $userpasswd
+ } else {
+ set userpswd [find userpassword $router]
+ if { "$userpswd" == "" } { set userpswd $passwd }
+ }
+
+ # Figure out prompts
+ set u_prompt [find userprompt $router]
+ if { "$u_prompt" == "" } { set u_prompt "(Username|login| Login):" }
+ set p_prompt [find passprompt $router]
+ if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" }
+
+ # Figure out cypher type
+ if {[info exists cypher]} {
+ # command line cypher type
+ set cyphertype $cypher
+ } else {
+ set cyphertype [find cyphertype $router]
+ if { "$cyphertype" == "" } { set cyphertype "3des" }
+ }
+
+ # Figure out connection method
+ set cmethod [find method $router]
+ if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }
+
+ # Login to the router
+ if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} {
+ continue
+ }
+
+ if { $do_command } {
+ if {[run_commands $prompt $command]} {
+ continue
+ }
+ } elseif { $do_script } {
+ send "lines 0\r"
+ expect $prompt {}
+ source $sfile
+ close
+ } else {
+ label $router
+ log_user 1
+ interact
+ }
+
+ # End of for each router
+ wait
+ sleep 0.3
+}
+exit 0
diff --git a/bin/arancid.in b/bin/arancid.in
new file mode 100755
index 0000000..5003ddd
--- /dev/null
+++ b/bin/arancid.in
@@ -0,0 +1,281 @@
+#!@PERLV_PATH@
+##
+## Hacked version of rancid for Alteon WebOS switches
+## tested with: ad3 v8.1.18
+## afort@choqolat.org (andrew fort)
+##
+##
+## Copyright (C) 1997 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## 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.
+##
+##
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# arancid - Alteon WebOS plugin for rancid
+#
+# usage: arancid [-d] [-l] [-f filename | $host]
+#
+use Getopt::Std;
+getopts('dflm');
+$log = $opt_l;
+$debug = $opt_d;
+$file = $opt_f;
+$host = $ARGV[0];
+$clean_run = 0;
+$found_end = 0;
+$prompt = "#";
+$timeo = 90; # clogin timeout in seconds
+
+# This routine is used to print out the router configuration
+sub ProcessHistory {
+ my($new_hist_tag,$new_command,$command_string,@string)=(@_);
+ if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
+ print eval "$command \%history";
+ undef %history;
+ }
+ if (($new_hist_tag) && ($new_command) && ($command_string)) {
+ if ($history{$command_string}) {
+ $history{$command_string} = "$history{$command_string}@string";
+ } else {
+ $history{$command_string} = "@string";
+ }
+ } elsif (($new_hist_tag) && ($new_command)) {
+ $history{++$#history} = "@string";
+ } else {
+ print "@string";
+ }
+ $hist_tag = $new_hist_tag;
+ $command = $new_command;
+ 1;
+}
+
+sub numerically { $a <=> $b; }
+
+# This is a sort routing that will sort numerically on the
+# keys of a hash as if it were a normal array.
+sub keynsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort numerically keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# keys of a hash as if it were a normal array.
+sub keysort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort keys(%lines)) {
+ $sorted_lines[$i] = $lines{$key};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routing that will sort on the
+# values of a hash as if it were a normal array.
+sub valsort{
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $key (sort values %lines) {
+ $sorted_lines[$i] = $key;
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a numerical sort routing (ascending).
+sub numsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $num (sort {$a <=> $b} keys %lines) {
+ $sorted_lines[$i] = $lines{$num};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# This is a sort routine that will sort on the
+# ip address when the ip address is anywhere in
+# the strings.
+sub ipsort {
+ local(%lines)=@_;
+ local($i) = 0;
+ local(@sorted_lines);
+ foreach $addr (sort sortbyipaddr keys %lines) {
+ $sorted_lines[$i] = $lines{$addr};
+ $i++;
+ }
+ @sorted_lines;
+}
+
+# These two routines will sort based upon IP addresses
+sub ipaddrval {
+ my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);
+ $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));
+}
+sub sortbyipaddr {
+ &ipaddrval($a) <=> &ipaddrval($b);
+}
+
+# This routine parses "/info/sys" (cf. show version)
+sub ShowVersion {
+ print STDERR " In ShowVersion: $_" if ($debug);
+
+ while (<INPUT>) {
+ tr/\015//d;
+ last if (/^>>.*$prompt/);
+ next if(/^(\s*|\s*$cmd\s*)$/);
+
+ /^(ACEdirector.*|ACEswitch.*|Alteon.*)/i &&
+ ProcessHistory("COMMENTS","keysort","A1", "\/\*Model: $1\n") && next;
+ /^Software Version\s+(.*?)\s\((.*)\)/i &&
+ ProcessHistory("COMMENTS","keysort","B1", "\/\*Image: Software: $1 ($2)\n") && next;
+ /^Hardware Part No:\s+(.*?)\s+/i &&
+ ProcessHistory("COMMENTS","keysort","A2", "\/\*Hardware part no: $1\n") && next;
+ /^MAC address:\s+([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})/i &&
+ ProcessHistory("COMMENTS","keysort","C1", "\/\*Base MAC address: $1\n") && next;
+ }
+ return(0);
+}
+
+# This routine processes a "/cfg/dump"
+sub WriteTerm {
+ print STDERR " In WriteTerm: $_" if ($debug);
+
+ # eat the header line
+ #$junk = <INPUT>;
+
+ # now just copy it verbatim to the history file
+ while (<INPUT>) {
+ tr/\015//d;
+ last if(/^>>.*$prompt/);
+ chop;
+ print $ENV{'NOCOMMSTR'};
+ /(rcomm|wcomm|t1com|t2com)(\s+)(.*)/ &&
+ ProcessHistory("","","","\/\*\t$1$2\"<removed>\"\n") && next;
+ #if (/^\s*snmp/ && defined($ENV{'NOCOMMSTR'})) {
+ # /snmp (getcomm|setcomm|trapcomm)(\s+)(\S*)/ &&
+ # ProcessHistory("","","","- snmp $1$2\"<removed>\"\n") && next;
+ #}
+ next if (/^\/\* Configuration dump taken/i);
+ next if (/^\/\* Version.*Base MAC.*/i);
+
+ if (/^\/script end/) {
+ $found_end = 1;
+ ProcessHistory("","","","$_\n");
+ return(1);
+ }
+
+ ProcessHistory("","","","$_\n");
+ }
+ return(0);
+}
+
+# dummy function
+sub DoNothing {print STDOUT;}
+
+# Main
+%commands=(
+ '/info/sys' => "ShowVersion",
+ '/cfg/dump' => "WriteTerm",
+);
+# keys() doesnt return things in the order entered and the order of the
+# cmds is important (show version first and write term last). pita
+@commands=(
+ "/info/sys",
+ "/cfg/dump",
+);
+$cisco_cmds=join(";",@commands);
+$cmds_regexp=join("|",@commands);
+
+open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
+select(OUTPUT);
+# make OUTPUT unbuffered if debugging
+if ($debug) { $| = 1; }
+
+if ($file) {
+ print STDERR "opening file $host\n" if ($debug);
+ print STDOUT "opening file $host\n" if ($log);
+ open(INPUT,"<$host") || die "open failed for $host: $!\n";
+} else {
+ print STDERR "executing alogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($debug);
+ print STDOUT "executing alogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($log);
+ if (defined($ENV{NOPIPE})) {
+ system "alogin -t $timeo -c \"$cisco_cmds\" $host </dev/null > $host.raw 2>&1" || die "alogin failed for $host: $!\n";
+ open(INPUT, "< $host.raw") || die "alogin failed for $host: $!\n";
+ } else {
+ open(INPUT,"alogin -t $timeo -c \"$cisco_cmds\" $host </dev/null |") || die "alogin failed for $host: $!\n";
+ }
+}
+
+ProcessHistory("","","","\/\*RANCID-CONTENT-TYPE: alteon\n\/\*\n");
+ProcessHistory("COMMENTS","keysort","B0","\/\*\n");
+ProcessHistory("COMMENTS","keysort","F0","\/\*\n");
+TOP: while(<INPUT>) {
+ tr/\015//d;
+ if (/^>>.*$prompt exit/) {
+ $clean_run=1;
+ last;
+ }
+
+ while (/>>.*$prompt\s*($cmds_regexp)\s*$/) {
+ $cmd = $1;
+ if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+#)/)[0]; }
+ print STDERR ("HIT COMMAND:$_") if ($debug);
+ if (!defined($commands{$cmd})) {
+ print STDERR "found unexpected command - \"$cmd\"\n";
+ $clean_run = 0;
+ last TOP;
+ }
+ $rval = &{$commands{$cmd}};
+ delete($commands{$cmd});
+ if ($rval == -1) {
+ $clean_run = 0;
+ last TOP;
+ }
+ }
+}
+print STDOUT "Done $logincmd: $_\n" if ($log);
+# Flush History
+ProcessHistory("","","","");
+# Cleanup
+close(INPUT);
+close(OUTPUT);
+
+if (defined($ENV{NOPIPE})) {
+ unlink("$host.raw") if (! $debug);
+}
+
+# check for completeness
+if (scalar(%commands) || !$clean_run || !$found_end) {
+ if (scalar(%commands)) {
+ printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
+ printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ }
+ if (!$clean_run || !$found_end) {
+ print STDOUT "End of run not found\n";
+ print STDERR "End of run not found\n" if ($debug);
+ system("/usr/bin/tail -1 $host.new");
+ }
+ unlink "$host.new" if (! $debug);
+}
diff --git a/bin/cat5rancid.in b/bin/cat5rancid.in
index cf0583d..c5406b0 100755
--- a/bin/cat5rancid.in
+++ b/bin/cat5rancid.in
@@ -1047,8 +1047,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/clogin.in b/bin/clogin.in
index 40d0d57..d1894b6 100755
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -60,7 +60,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -128,7 +128,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -173,7 +173,7 @@ for {set i 0} {$i < $argc} {incr i} {
set autoenable 1
set enable 0
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -183,7 +183,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -249,16 +249,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -274,21 +274,21 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
foreach prog [lrange $cmethod 0 end] {
if ![string compare $prog "telnet"] {
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: telnet failed: $reason\n"
+ send_user "\nError: telnet failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "ssh"] {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: ssh failed: $reason\n"
+ send_user "\nError: ssh failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "rsh"] {
if [ catch {spawn rsh -l $user $router} reason ] {
- send_user "Error: rsh failed: $reason\n"
+ send_user "\nError: rsh failed: $reason\n"
exit 1
}
} else {
- puts "ERROR: unknown connection method: $prog"
+ puts "\nError: unknown connection method: $prog"
return 1
}
incr progs -1
@@ -328,29 +328,29 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
if !$progs {
send_user "\nError: Connection Refused ($prog)\n"; return 1
}
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} -nocase "unknown host\r" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
catch {close};
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
- -re "Host key not found .* \(yes\/no\)\?" {
+ -re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" {
send "yes\r"
- send_user "Host $router added to the list of known hosts.\n"
+ send_user "\nHost $router added to the list of known hosts.\n"
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "$u_prompt" { send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
- "Login invalid" { send_user "Error: Invalid login\n"; vatch {close}; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
+ "Login invalid" { send_user "\nError: Invalid login\n"; vatch {close}; wait; return 1 }
-re "$p_prompt" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -363,14 +363,14 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
send "$passwd\r"
}
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "$e_prompt" { send "$enapasswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { break; }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
wait
@@ -379,7 +379,7 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}
set in_proc 0
@@ -398,8 +398,8 @@ proc do_enable { enauser enapasswd } {
-re "$e_prompt" { send "$enapasswd\r"; exp_continue}
"#" { set prompt "#" }
"(enable)" { set prompt "> (enable) " }
- denied { send_user "Error: Check your Enable passwd\n"; return 1}
- "% Bad passwords" { send_user "Error: Check your Enable passwd\n"
+ denied { send_user "\nError: Check your Enable passwd\n"; return 1}
+ "% Bad passwords" { send_user "\nError: Check your Enable passwd\n"
return 1
}
}
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 58f6211..c61a0a4 100755
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -76,8 +76,8 @@ grep -v '^#' router.db > routers.db
cut -d: -f1,2 routers.db | sort -u > routers.all.new
if [ ! -f routers.all ] ; then touch routers.all; fi
diff routers.all routers.all.new > /dev/null 2>&1; RALL=$?
-@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
- if ($F[2] =~ /^down$/i);}' routers.db | sort -u > routers.down.new
+@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print join(":", @F)."\n")
+ if ($F[2] !~ /^up$/i);}' routers.db | sort -u > routers.down.new
if [ ! -f routers.down ] ; then touch routers.down; fi
diff routers.down routers.down.new > /dev/null 2>&1; RDOWN=$?
@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
diff --git a/bin/elogin.in b/bin/elogin.in
index 89f7a99..46f459d 100755
--- a/bin/elogin.in
+++ b/bin/elogin.in
@@ -54,7 +54,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -115,7 +115,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -159,7 +159,7 @@ for {set i 0} {$i < $argc} {incr i} {
} -autoenable {
# ignore -autoenable
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -169,7 +169,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -236,16 +236,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -260,7 +260,7 @@ proc login { router user userpswd passwd prompt cyphertype } {
# Telnet to the router & try to login.
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: failed to telnet: $reason\n"
+ send_user "\nError: failed to telnet: $reason\n"
exit 1
}
sleep 0.3
@@ -291,23 +291,23 @@ proc login { router user userpswd passwd prompt cyphertype } {
close; wait
sleep 0.3
expect eof
- send_user "Error: Connection Refused\n"; wait; return 1
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ send_user "\nError: Connection Refused\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} "Unknown host\r\n" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
expect eof
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "$u_prompt" { send "$user\r"
expect {
- "Login incorrect" { send_user "Error: Couldn't login\n";
+ "Login incorrect" { send_user "\nError: Couldn't login\n";
catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "$p_prompt" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -315,17 +315,17 @@ proc login { router user userpswd passwd prompt cyphertype } {
}
-re "$p_prompt" { send "$passwd\r"
expect {
- "Password incorrect" { send_user "Error: Couldn't login\n";
+ "Password incorrect" { send_user "\nError: Couldn't login\n";
catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
- "Password incorrect" { send_user "Error: Check your password for $router\n";
+ "Password incorrect" { send_user "\nError: Check your password for $router\n";
catch {close}; wait; return 1 }
"$prompt" { }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
wait
diff --git a/bin/erancid.in b/bin/erancid.in
index 1106018..0377612 100755
--- a/bin/erancid.in
+++ b/bin/erancid.in
@@ -247,8 +247,7 @@ while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host elogin error: $_");
print STDERR ("$host elogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/flogin.in b/bin/flogin.in
index 6c82594..ac60bf3 100755
--- a/bin/flogin.in
+++ b/bin/flogin.in
@@ -62,7 +62,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -130,7 +130,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -171,7 +171,7 @@ for {set i 0} {$i < $argc} {incr i} {
set autoenable 1
set enable 0
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -181,7 +181,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -247,16 +247,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -269,7 +269,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
# Telnet to the router & try to login.
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: failed to telnet: $reason\n"
+ send_user "\nError: failed to telnet: $reason\n"
exit 1
}
sleep 0.3
@@ -307,7 +307,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
close; wait
if { $tryssh } {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
set tryssh 0
@@ -315,18 +315,18 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
exp_continue
} else {
expect eof
- send_user "Error: Connection Refused\n"; wait; return 1
+ send_user "\nError: Connection Refused\n"; wait; return 1
}
- } eof { send_user "Error: Couldn't login\n"; wait; return 1
+ } eof { send_user "\nError: Couldn't login\n"; wait; return 1
} "Unknown host\r\n" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
expect eof
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
expect eof
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "Host key not found .* \(yes\/no\)\?" {
send "yes\r"
@@ -334,13 +334,13 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "(Username:|login:|Name :)" {
sleep 1;
send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-re "\[Pp]assword:" { send "$userpswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
@@ -348,14 +348,14 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
}
"\[Pp]assword:" { send "$passwd\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"Password:" { send "$enapasswd\r" }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "quit"
wait
@@ -364,7 +364,7 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
set in_proc 0
return 0
@@ -381,8 +381,8 @@ proc do_enable { enauser enapasswd } {
-re "(Username|User Name):" { send "$enauser\r"; exp_continue}
"Password:" { send "$enapasswd\r"; exp_continue}
"#" { }
- denied { send_user "Error: Check your Enable passwd\n"; return 1}
- "% Bad passwords" { send_user "Error: Check your Enable passwd\n"
+ denied { send_user "\nError: Check your Enable passwd\n"; return 1}
+ "% Bad passwords" { send_user "\nError: Check your Enable passwd\n"
return 1
}
}
diff --git a/bin/francid.in b/bin/francid.in
index 560d959..66c4b75 100755
--- a/bin/francid.in
+++ b/bin/francid.in
@@ -341,8 +341,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host flogin error: $_");
print STDERR ("$host flogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/jlogin.in b/bin/jlogin.in
index e0ac844..a74cff4 100755
--- a/bin/jlogin.in
+++ b/bin/jlogin.in
@@ -54,7 +54,7 @@ if {[ info exists env(CISCO_USER) ] } {
# (without options) on all machines/OSes I've been on recently -
# unlike whoami or id -nu.
if [ catch {exec id} reason ] {
- send_error "Error: could not exec id: $reason\n"
+ send_error "\nError: could not exec id: $reason\n"
exit 1
}
regexp {\(([^)]*)} "$reason" junk default_user
@@ -106,7 +106,7 @@ for {set i 0} {$i < $argc} {incr i} {
set sfile [ lindex $argv $i ]
}
if { ! [ file readable $sfile ] } {
- send_user "Error: Can't read $sfile\n"
+ send_user "\nError: Can't read $sfile\n"
exit 1
}
set do_script 1
@@ -144,7 +144,7 @@ for {set i 0} {$i < $argc} {incr i} {
set cypher [ lindex $argv $i ]
}
} -* {
- send_user "Error: Unknown argument! $arg\n"
+ send_user "\nError: Unknown argument! $arg\n"
send_user $usage
exit 1
} default {
@@ -154,7 +154,7 @@ for {set i 0} {$i < $argc} {incr i} {
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
- send_user "Error: $usage"
+ send_user "\nError: $usage"
}
# Only be quiet if we are running a script (it can log its output
@@ -220,16 +220,16 @@ proc find {var router} {
proc source_password_file { password_file } {
global env
if { ! [file exists $password_file] } {
- send_user "Error: password file ($password_file) does not exist\n"
+ send_user "\nError: password file ($password_file) does not exist\n"
exit 1
}
file stat $password_file fileinfo
if { [expr ($fileinfo(mode) & 007)] != 0000 } {
- send_user "Error: $password_file must not be world readable/writable\n"
+ send_user "\nError: $password_file must not be world readable/writable\n"
exit 1
}
if [ catch {source $password_file} reason ] {
- send_user "Error: $reason\n"
+ send_user "\nError: $reason\n"
exit 1
}
}
@@ -244,7 +244,7 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
foreach prog [lrange $cmethod 0 end] {
if ![string compare $prog "telnet"] {
if [ catch {spawn telnet $router} reason ] {
- send_user "Error: telnet failed: $reason\n"
+ send_user "\nError: telnet failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "ssh"] {
@@ -253,22 +253,22 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
# spaces correctly.
if {$identfile != ""} {
if [ catch {spawn ssh -c $cyphertype -x -l $user -i $identfile $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
} else {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "Error: failed to ssh: $reason\n"
+ send_user "\nError: failed to ssh: $reason\n"
exit 1
}
}
} elseif ![string compare $prog "rsh"] {
if [ catch {spawn rsh -l $user $router} reason ] {
- send_user "Error: rsh failed: $reason\n"
+ send_user "\nError: rsh failed: $reason\n"
exit 1
}
} else {
- puts "ERROR: unknown connection method: $prog"
+ puts "\nError: unknown connection method: $prog"
return 1
}
incr progs -1
@@ -308,32 +308,32 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
send_user "\nError: Connection Refused ($prog)\n"; return 1
}
}
- eof { send_user "Error: Couldn't login\n"; wait; return 1
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1
} -nocase "unknown host\r\n" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
} "Host is unreachable" {
catch {close};
- send_user "Error: Host Unreachable!\n"; wait; return 1
+ send_user "\nError: Host Unreachable!\n"; wait; return 1
} "No address associated with name" {
catch {close};
- send_user "Error: Unknown host\n"; wait; return 1
+ send_user "\nError: Unknown host\n"; wait; return 1
}
-re "Enter passphrase for RSA key '\[^'\]*': " {
send_user "\nKey has passphrase!\n"
send "$passphrase\r"
exp_continue }
- -re "Host key not found .* \(yes\/no\)\?" {
+ -re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" {
send "yes\r"
- send_user "Host $router added to the list of known hosts.\n"
+ send_user "\nHost $router added to the list of known hosts.\n"
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "Error: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
return 1 }
-re "(Username|\[\r\n]login):" { send "$user\r"
expect {
- eof { send_user "Error: Couldn't login\n";
+ eof { send_user "\nError: Couldn't login\n";
wait; return 1 }
-re "\[Pp]assword:" { send "$passwd\r" }
"$prompt" { set in_proc 0; return 0 }
@@ -342,13 +342,13 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
}
"\[Pp]assword:" { send "$passwd\r"
expect {
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
"$prompt" { set in_proc 0; return 0 }
}
exp_continue
}
"$prompt" { break; }
- denied { send_user "Error: Check your passwd for $router\n"
+ denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "quit"
wait
@@ -357,7 +357,7 @@ proc login { router user passwd prompt cmethod cyphertype identfile} {
return 1
}
}
- "% Bad passwords" {send_user "Error: Check your passwd for $router\n"; return 1 }
+ "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}
set in_proc 0
diff --git a/bin/jrancid.in b/bin/jrancid.in
index 6e2311f..91bbf54 100755
--- a/bin/jrancid.in
+++ b/bin/jrancid.in
@@ -392,7 +392,7 @@ sub DoNothing {print STDOUT;}
"show chassis environment" => "ShowChassisEnvironment",
"show chassis firmware" => "ShowChassisFirmware",
"show chassis fpc detail" => "ShowChassisFpcDetail",
- "show chassis hardware" => "ShowChassisHardware",
+ "show chassis hardware detail" => "ShowChassisHardware",
"show chassis routing-engine" => "ShowChassisRoutingEngine",
"show chassis scb" => "ShowChassisSCB",
"show chassis sfm detail" => "ShowChassisSCB",
@@ -407,7 +407,7 @@ sub DoNothing {print STDOUT;}
"show chassis environment",
"show chassis firmware",
"show chassis fpc detail",
- "show chassis hardware",
+ "show chassis hardware detail",
"show chassis routing-engine",
"show chassis scb",
"show chassis sfm detail",
@@ -447,7 +447,6 @@ ProcessHistory("","","","# RANCID-CONTENT-TYPE: juniper\n#\n");
TOP: while(<INPUT>) {
tr/\015//d;
if (/^Error:/) {
- s/^.*Error:/Error:/;
print STDOUT ("$host jlogin error: $_");
print STDERR ("$host jlogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/rancid-fe.in b/bin/rancid-fe.in
index 8e5d333..7a6c7ff 100755
--- a/bin/rancid-fe.in
+++ b/bin/rancid-fe.in
@@ -37,6 +37,8 @@ if ($vendor =~ /^cisco$/i) {
exec('francid', $router);
} elsif ($vendor =~ /^redback$/i) {
exec('rrancid', $router);
+} elsif ($vendor =~ /^alteon$/i) {
+ exec('arancid', $router);
}
printf(STDERR "unknown router manufacturer for $router: $vendor\n");
diff --git a/bin/rancid.in b/bin/rancid.in
index 065697a..d8b3694 100755
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -194,6 +194,8 @@ sub ShowVersion {
$type = "AGS+";
} elsif ( $1 eq "2511" || $1 eq "2524" || $1 eq "AS2511-RJ") {
$type = "2500";
+ } elsif ( $1 =~ /261[01]/ || $1 =~ /262[01]/ ) {
+ $type = "2600";
} elsif ( $1 eq "3620" || $1 eq "3640") {
$type = "3600";
} elsif ( $1 eq "RSP7000") {
@@ -208,6 +210,8 @@ sub ShowVersion {
$type = "7200";
} elsif ( $1 =~ /1200[48]\/GRP/ || $1 =~ /1201[26]\/GRP/) {
$type = "12000";
+ } elsif ( $1 =~ /1201[26]-8R\/GRP/) {
+ $type = "12000";
} elsif ( $1 =~ /WS-C29/) {
$type = "2900XL";
$device = "switch";
@@ -429,7 +433,7 @@ sub DirSlotN {
return(1) if /\%Error: No such file or directory/;
return(1) if /No space information available/;
return(-1) if /\%Error calling/;
- return(-1) if /: device being squeezed/; # Flash is busy
+ return(-1) if /(: device being squeezed|ATA_Status time out)/i; # busy
return(-1) if (/command authorization failed/i);
return(1) if /(Open device \S+ failed|Error opening \S+:)/;
ProcessHistory("FLASH","","","!Flash: $dev: $_");
@@ -1112,8 +1116,7 @@ TOP: while(<INPUT>) {
$clean_run=1;
last;
}
- if (/Error:/) {
- s/^.*Error:/Error:/;
+ if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
$clean_run=0;
diff --git a/bin/rrancid.in b/bin/rrancid.in
index 9d40591..9d2663b 100755
--- a/bin/rrancid.in
+++ b/bin/rrancid.in
@@ -266,9 +266,6 @@ sub FlailHelplessly {
"show slot table",
"show config"
);
-# dir /flash
-# dir /pcmcia0
-# dir /pcmcia1
$redback_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);