<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hello!</p>
<p><br>
</p>
<p>I'm trying to create a new rancid login file for an audiocodes device and I need a little help debugging what's going on & how to fix it.<br>
<br>
</p>
I've created audiologin which can successfully loginto and run all the commands required (per FAQ 3.2).  However, when I try using audiorancid (based upon hrancid) to call audiologin I'm getting an error that it can't run the commands which does not make sense
 to me yet.  What I see as a result of CLI running audiorancid is it's creating the file to write to(it shows up in the file system), and then it attempts to 'select' this file and then proceeds to error out.  This doesn't make sense to me as the excerpt from
 hrancid (which works against HP switches), is identical (minus debug commands) and does not have this problem.  Any help is appriciated!<br>
<br>
Thank you in advance,</div>
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<br>
<br>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">I've created the type 'ac' as defined in /etc/base.types.conf so when/if rancid-run gets ahold of it it'll find the correct files.</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"></p>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
ac;script;audiorancid</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
ac;login;audiologin</div>
<div><br>
</div>
<div>rancid@server:~/var/rancid-3.4.99/logs$ audiorancid 10.174.0.247</div>
<div>commandstr: show storage-history;show system active-alarms;show system assembly;show system feature;show system version;show voip firewall;show voip tls certificate;show running-config</div>
<div>Debug 1</div>
<div>Debug 2</div>
<div>10.174.0.247: missed cmd(s): all commands</div>
<div><br>
</div>
<div>--- Output of working audiologin ---<br>
<div>rancid@truck:~/bin$ audiologin -c "show storage-history" 10.174.0.247</div>
<div>10.174.0.247</div>
<div>spawn ssh -x -l LOGIN 10.174.0.247</div>
<div>Welcome to AudioCodes CLI</div>
<div>LOGIN@10.174.0.247's password: </div>
<div>Last login: Fri Sep 09 2016 at 15:23:15</div>
<div><br>
</div>
<div>Mediant 1000> </div>
<div><br>
</div>
<div>Mediant 1000> </div>
<div><br>
</div>
<div>Mediant 1000> </div>
<div><br>
</div>
<div>Mediant 1000> </div>
<div><br>
</div>
<div>Mediant 1000>  show storage-history</div>
<div>No Storage History Files</div>
<div><br>
</div>
<div>Mediant 1000>quitConnection to 10.174.0.247 closed by remote host.</div>
<div>Connection to 10.174.0.247 closed.</div>
<div><br>
</div>
<br>
--- End of Output of working audiologin ---</div>
<div><br>
</div>
--- Excript of hrancid ---<br>
<div>if ($opt_C) {</div>
<div>    print "hlogin -t $timeo -c\'$commandstr\' $host\n";</div>
<div>    exit(0);</div>
<div>}</div>
<div>open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";</div>
<div>select(OUTPUT);</div>
<div># make OUTPUT unbuffered if debugging</div>
<div>if ($debug) { $| = 1; }</div>
<div><br>
</div>
<div>if ($file) {</div>
<div>    print(STDERR "opening file $host\n") if ($debug || $log);</div>
<div>    open(INPUT,"<$host") || die "open failed for $host: $!\n";</div>
<div>} else {</div>
<div>    print(STDERR "executing hlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);</div>
<div>    if (defined($ENV{NOPIPE}) && $ENV{NOPIPE} =~ /^YES/i) {</div>
<div>        system "hlogin -t $timeo -c \"$commandstr\" $host </dev/null > $host.raw 2>&1" || die "hlogin failed for $host: $!\n";</div>
<div>        open(INPUT, "< $host.raw") || die "hlogin failed for $host: $!\n";</div>
<div>    } else {</div>
<div>        open(INPUT,"hlogin -t $timeo -c \"$commandstr\" $host </dev/null |") || die "hlogin failed for $host: $!\n";</div>
<div>    }</div>
<div>}</div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">--- Excript of hrancid ---</span><br>
</div>
<br>
<br>
--- Contents of audiorancid ---<br>
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#! /usr/bin/perl</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## $Id: hrancid.in 3345 2016-04-04 00:24:36Z heas $</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## rancid 3.4.99</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## Copyright (c) 1997-2016 by Terrapin Communications, Inc.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## All rights reserved.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## This code is derived from software contributed to and maintained by</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan,</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## Pete Whiting, Austin Schutz, and Andrew Fort.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## Redistribution and use in source and binary forms, with or without</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## modification, are permitted provided that the following conditions</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## are met:</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## 1. Redistributions of source code must retain the above copyright</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    notice, this list of conditions and the following disclaimer.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## 2. Redistributions in binary form must reproduce the above copyright</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    notice, this list of conditions and the following disclaimer in the</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    documentation and/or other materials provided with the distribution.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## 3. All advertising materials mentioning features or use of this software</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    must display the following acknowledgement:</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##        This product includes software developed by Terrapin Communications,</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##        Inc. and its contributors for RANCID.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## 4. Neither the name of Terrapin Communications, Inc. nor the names of its</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    contributors may be used to endorse or promote products derived from</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    this software without specific prior written permission.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## 5. It is requested that non-binding fixes and modifications be contributed</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##    back to Terrapin Communications, Inc.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">##</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">## POSSIBILITY OF SUCH DAMAGE.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># Amazingly hacked version of Hank's rancid - this one tries to</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># deal with HP procurves.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#  RANCID - Really Awesome New Cisco confIg Differ</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># usage: hrancid [-dltCV] [-f filename | hostname]</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">use Getopt::Std;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">getopts('dflt:CV');</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($opt_V) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print "rancid 3.4.99\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    exit(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$log = $opt_l;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$debug = $opt_d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$file = $opt_f;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$host = $ARGV[0];</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$clean_run = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$found_end = 0;                         # unused - hp lacks an end-of-config tag</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$timeo = 90;                            # audiologin timeout in seconds</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my(@commandtable, %commands, @commands);# command lists</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my($aclsort) = ("ipsort");              # ACL sorting mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my($filter_commstr);                    # SNMP community string filtering</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my($filter_osc);                        # oscillating data filtering mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my($filter_pwds);                       # password filtering mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">my($systeminfo) = 0;                    # show system-information</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine is used to print out the router configuration</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ProcessHistory {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    my($new_hist_tag,$new_command,$command_string,@string) = (@_);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if ((($new_hist_tag ne $hist_tag) || ($new_command ne $command))</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        && scalar(%history)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print eval "$command \%history";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        undef %history;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (($new_hist_tag) && ($new_command) && ($command_string)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if ($history{$command_string}) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $history{$command_string} = "$history{$command_string}@string";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $history{$command_string} = "@string";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    } elsif (($new_hist_tag) && ($new_command)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $history{++$#history} = "@string";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print "@string";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $hist_tag = $new_hist_tag;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $command = $new_command;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub numerically { $a <=> $b; }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This is a sort routine that will sort numerically on the</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># keys of a hash as if it were a normal array.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub keynsort {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(%lines) = @_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local($i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(@sorted_lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    foreach $key (sort numerically keys(%lines)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $sorted_lines[$i] = $lines{$key};</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $i++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    @sorted_lines;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This is a sort routine that will sort on the</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># keys of a hash as if it were a normal array.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub keysort {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(%lines) = @_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local($i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(@sorted_lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    foreach $key (sort keys(%lines)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $sorted_lines[$i] = $lines{$key};</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $i++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    @sorted_lines;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This is a sort routine that will sort on the</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># values of a hash as if it were a normal array.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub valsort{</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(%lines) = @_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local($i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(@sorted_lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    foreach $key (sort values %lines) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $sorted_lines[$i] = $key;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $i++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    @sorted_lines;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This is a numerical sort routine (ascending).</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub numsort {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(%lines) = @_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local($i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(@sorted_lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    foreach $num (sort {$a <=> $b} keys %lines) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $sorted_lines[$i] = $lines{$num};</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $i++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    @sorted_lines;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This is a sort routine that will sort on the</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># ip address when the ip address is anywhere in</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># the strings.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ipsort {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(%lines) = @_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local($i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    local(@sorted_lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    foreach $addr (sort sortbyipaddr keys %lines) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $sorted_lines[$i] = $lines{$addr};</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $i++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    @sorted_lines;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># These two routines will sort based upon IP addresses</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ipaddrval {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $a[3] + 256 * ($a[2] + 256 * ($a[1] +256 * $a[0]));</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub sortbyipaddr {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    &ipaddrval($a) <=> &ipaddrval($b);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show config files"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowConfigFiles {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowConfigFiles: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","H0",";$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show version"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowVersion {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowVersion: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if(/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if(/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if /^uptime/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/^image//i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/^\s*//g;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","C1", ";Image: $_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show flash"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowFlash {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowFlash: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^\s*\^\s*$/;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","D0",";Flash: $_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show system-information" or "show system information"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowSystem {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowSystem: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if ($systeminfo) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $_ = <INPUT>;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(0) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(0) if /^% Unknown command/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/memory\s+-\s+total\s+:\s+(\S+)/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            my($mem) = $1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $mem =~ s/,//g;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $mem /= (1024 * 1024);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("COMMENTS","keysort","B0",";Memory: " . int($mem) .</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                           "M\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /serial\s+number\s+:\s+(\S+)/i &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("COMMENTS","keysort","A1",";Serial Number: $1\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /firmware\s+revision\s+:\s+(\S+)/i &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("COMMENTS","keysort","C0",";Image: Firmware $1\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /rom\s+version\s+:\s+(\S+)/i &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("COMMENTS","keysort","C1",";Image: ROM $1\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $systeminfo = 1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show module".</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowModule {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowModule: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    my(@lines);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    my($slot);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return if (/^\s*\^$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","E0","; $_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show stack"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowStack {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowStack: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/stacking - (Stacking Status).*/$1/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/\s*members unreachable .*$//i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if /^uptime/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","F0",";$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /auto grab/i && last;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show tech transceivers"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowTechTransceivers {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowTransceivers: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/ Technical Information//i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^ATTENTION: You are entering a diagnostic mode/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                return(1) if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                last if (/^(\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","G0",";$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine parses "show config status"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub ShowConfigStatus {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In ShowConfigStatus: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if (/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^(\s*|\s*$cmd\s*)$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(1) if /^(Invalid|Ambiguous) input:/i;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^Running configuration is same as /);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        next if (/^$/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("COMMENTS","keysort","H0","; $_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># This routine processes a "write term"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">sub WriteTerm {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print STDERR "    In WriteTerm: $_" if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/$prompt\s*(exit|logout)\s*$/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $clean_run=1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            last;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last if(/^$prompt/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        return(-1) if (/command authorization failed/i);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # the pager can not be disabled per-session</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/^<-+ More -+>\s*//;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/^$/;/;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # skip the crap</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^running configuration:/i && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # filter out any RCS/CVS tags to avoid confusing local CVS storage</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        s/\$(Revision|Id):/ $1:/;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^; (\S+) configuration editor;/i &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("COMMENTS","keysort","A0",";Chassis type: $1\n") &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";\n;Running config file:\n$_") &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order logging statements - doesnt appear to do syslog as of right now</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^logging (\d+\.\d+\.\d+\.\d+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("LOGGING","ipsort","$1","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # no so sure this match is correct.  show running doesnt seem to</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # actually o/p anything after "password (manager|operator)"</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(\s*)password (manager|operator)?/ && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("LINE-PASS","","",";$1password $2 <removed>\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(snmp-server community) (\S+)/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            if ($filter_commstr) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("SNMPSERVERCOMM","keysort","$_",</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                        ";$1 <removed>$'") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order/prune snmp-server host statements - it actually appears to do</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # the sortting for us, but just in case it changes ...</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # we only prune lines of the form</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # snmp-server host a.b.c.d <community></span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            if ($filter_commstr) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                my($ip) = $1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                my($line) = "snmp-server host $ip";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                my(@tokens) = split(' ', $');</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                my($token);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                while ($token = shift(@tokens)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    if ($token eq 'version') {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                        $line .= " " . join(' ', ($token, shift(@tokens)));</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                        $line .= " " . $token;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                        $line = ";$line " . join(' ', ("<removed>", join(' ',@tokens)));</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                        last;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order/prune tacacs/radius server statements</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 key <removed>\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(tacacs-server host \d+\.\S+) key / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 key <removed>\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # prune passwords from stack member statements</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(stack member .* password )\S+/ && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1<removed>$'");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order arp lists</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ip arp\s+(\d+\.\d+\.\d+\.\d+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("ARP","$aclsort","$1","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n")</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # blech!!!!</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^auto-tftp / &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # the rest are from rancid (i.e.: cisco), but suspect they will someday</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # be applicable or close to it.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^tftp-server flash /   && next; # kill any tftp remains</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ntp clock-period /    && next; # kill ntp clock-period</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ length /             && next; # kill length on serial lines</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ width /              && next; # kill width on serial lines</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("ENABLE","","",";$1$2 <removed>\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^username (\S+)(\s.*)? password /) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            if ($filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("USER","keysort","$1",";username $1$2 password <removed>\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                ProcessHistory("USER","keysort","$1","$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(ip ftp password) / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 <removed>\n"); next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 <removed>\n"); next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 <removed>\n"); next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # sort route-maps</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^route-map (\S+)/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            my($key) = $1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            my($routemap) = $_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            while (<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                last if (/^$prompt/ || ! /^(route-map |[ !])/);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                if (/^route-map (\S+)/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    ProcessHistory("ROUTEMAP","keysort","$key","$routemap");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    $key = $1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    $routemap = $_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                } else  {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    $routemap .= $_;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("ROUTEMAP","keysort","$key","$routemap");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order access-lists</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order extended access-lists</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order alias statements</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # delete ntp auth password</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("","","",";$1 <removed>\n"); next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order ntp peers/servers</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("NTP","keysort",$sortkey,"$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order ip host line statements</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ip host line(\d+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("IPHOST","numsort","$1","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order ip nat source static statements</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ip nat (\S+) source static (\S+)/ &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            ProcessHistory("IP NAT $1","ipsort","$2","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # order ip rcmd lines</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        # catch anything that wasnt match above.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        ProcessHistory("","","","$_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    return(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># Main</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#@commandtable = (</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show version'                 => 'ShowVersion'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show flash'                   => 'ShowFlash'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show system-information'      => 'ShowSystem'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show system information'      => 'ShowSystem'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show module'                  => 'ShowModule'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show stack'                   => 'ShowStack'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show tech transceivers'       => 'ShowTechTransceivers'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show config files'            => 'ShowConfigFiles'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'show config status'           => 'ShowConfigStatus'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#       {'write term'                   => 'WriteTerm'}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">#);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">@commandtable = (</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show storage-history'         => 'ShowStorageHistory'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show system active-alarms'    => 'ShowSystemActiveAlarms'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show system assembly'         => 'ShowSystemAssembly'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show system feature'          => 'ShowSystemFeature'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show system version'          => 'ShowSystemVersion'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show voip firewall'           => 'ShowVoipFirewall'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show voip tls certificate'    => 'ShowVoipTlsCertificate'},</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        {'show running-config'          => 'ShowRunningConfig'}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># Use an array to preserve the order of the commands and a hash for mapping</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># commands to the subroutine and track commands that have been completed.</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">@commands = map(keys(%$_), @commandtable);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">%commands = map(%$_, @commandtable);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$commandcnt = scalar(keys %commands);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$commandstr=join(";",@commands);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">$cmds_regexp = join("|", map quotemeta($_), @commands);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if (length($host) == 0) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if ($file) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print(STDERR "Too few arguments: file name required\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        exit(1);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print(STDERR "Too few arguments: host name required\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        exit(1);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($opt_C) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print "audiologin -t $timeo -c\'$commandstr\' $host\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    exit(0);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("commandstr: $commandstr\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 1\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 2\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">select(OUTPUT);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 3\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># make OUTPUT unbuffered if debugging</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($debug) { $| = 1; }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($file) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print(STDERR "opening file $host\n") if ($debug || $log);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    open(INPUT,"<$host") || die "open failed for $host: $!\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">} else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    print(STDERR "executing audiologin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (defined($ENV{NOPIPE}) && $ENV{NOPIPE} =~ /^YES/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        system "audiologin -t $timeo -c \"$commandstr\" $host </dev/null > $host.raw 2>&1" || die "audiologin failed for $host: $!\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        open(INPUT, "< $host.raw") || die "audiologin failed for $host: $!\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        open(INPUT,"audiologin -t $timeo -c \"$commandstr\" $host </dev/null |") || die "audiologin failed for $host: $!\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 4\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># determine ACL sorting mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($ENV{"ACLSORT"} =~ /no/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $aclsort = "";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 5\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># determine community string filtering mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if (defined($ENV{"NOCOMMSTR"}) &&</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    ($ENV{"NOCOMMSTR"} =~ /yes/i || $ENV{"NOCOMMSTR"} =~ /^$/)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_commstr = 1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">} else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_commstr = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 6\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># determine oscillating data filtering mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_osc = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">} else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_osc = 1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 7\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># determine password filtering mode</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if ($ENV{"FILTER_PWDS"} =~ /no/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_pwds = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_pwds = 2;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">} else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    $filter_pwds = 1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 8\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("","","",";RANCID-CONTENT-TYPE: hp\n;\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","B0",";\n");        # memory info</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","C0",";\n");        # showversion</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","D0",";\n");        # showflash</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","E0",";\n");        # showmodule</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","F0",";\n");        # showstack</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","G0",";\n");        # showtechtransceivers</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","H0",";\n");        # showconfigfiles</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("COMMENTS","keysort","I0",";\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 9\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">TOP: while(<INPUT>) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    tr/\015//d;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (/$prompt\s*(exit|logout)\s*$/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $clean_run=1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (/^Error:/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print STDOUT ("$host audiologin error: $_");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print STDERR ("$host audiologin error: $_") if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $clean_run=0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        last;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    while (/#\s*($cmds_regexp)\s*$/) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $cmd = $1;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (!defined($prompt)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $prompt = ($_ =~ /^([^#]+)/)[0];</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $prompt =~ s/([][}{)(\\])/\\$1/g;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $prompt .= "[#>]";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print STDERR ("HIT COMMAND:$_") if ($debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if (! defined($commands{$cmd})) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            print STDERR "$host: found unexpected command - \"$cmd\"\n";</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $clean_run = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            last TOP;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        delete($commands{$cmd});</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if ($rval == -1) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            $clean_run = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            last TOP;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 10\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print STDOUT "Done $logincmd: $_\n" if ($log);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># Flush History</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">ProcessHistory("","","","");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># Cleanup</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">close(INPUT);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">close(OUTPUT);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if (defined($ENV{NOPIPE}) && $ENV{NOPIPE} =~ /^YES/i) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    unlink("$host.raw") if (! $debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">print ("Debug 11\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;"># check for completeness</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">if (scalar(%commands) || !$clean_run) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (scalar(keys %commands) eq $commandcnt) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        printf(STDERR "$host: missed cmd(s): all commands\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    } elsif (scalar(%commands)) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        my($count, $i) = 0;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        for ($i = 0; $i < $#commands; $i++) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            if ($commands{$commands[$i]}) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                if (!$count) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                } else {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                    printf(STDERR ", %s", $commands[$i]);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">                $count++;</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        if ($count) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">            printf(STDERR "\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    if (!$clean_run) {</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        print(STDERR "$host: End of run not found\n");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">        system("/usr/bin/tail -1 $host.new");</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    }</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">    unlink "$host.new" if (! $debug);</span><br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
<span style="color: rgb(33, 33, 33); font-size: 13.3333px;">}</span><br>
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">--- End of Contents of </span>audiorancid<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"> ---</span><br>
<p></p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div style="font-family:Tahoma; font-size:13px">
<div>
<div>
<p style="font-family:Tahoma; font-size:13px"></p>
<p style="font-family:Tahoma; font-size:13px"><br>
</p>
<p style="font-family:Tahoma; font-size:13px"><br>
</p>
<p>Robert Remsik</p>
<p>ACNS</p>
<p>Desk Phone: 970 491 7120</p>
<p>Robert.Remsik@colostate.edu</p>
<p style="font-family:Tahoma; font-size:13px"></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>