<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Alan,</span></div><div><span><var id="yui-ie-cursor"></var></span> </div><div><span>Thank you . Please see the below,</span></div><div><span></span> </div><div><span>1. Can telnet to device and authenticate manually</span></div><div><span></span> </div><div><span>2. /home/eserica/rancid/bin/hulogin -d 10.3.4.5 logs in successfully, and enables properly. Prompt is correct as well</span></div><div><span></span> </div><div><span>3. /home/eserica/rancid/bin/hulogin -t 90 -c"display current-configuration ; display version" 10.3.4.5 runs cleanly. commands are run neatly. automatic login and logout</span></div><div></div><span><div>4.[eserica@netflow logs]$ /home/eserica/rancid/bin/h3crancid -d 10.3.4.5<br>executing hulogin -t 90 -c"display version ; display current-configuration" 10.3.4.5<br>executing
hulogin -t 90 -c"display version ; display current-configuration" 10.3.4.5<br>sh: hulogin: command not found<br>10.3.4.5: missed cmd(s): display current-configuration,display version<br>10.3.4.5: missed cmd(s): display current-configuration,display version<br>10.3.4.5: End of run not found<br>10.3.4.5: End of run not found<br></div><div>The router.db</div><div>10.3.4.5:huawei:up</div><div> </div><div>The rancid-fe <br> 'huawei' => 'h3crancid',<br> </div><div>Don't understand why am getting such an output from /home/eserica/rancid/bin/h3crancid -d 10.3.4.5</div><div>Any comments on the above?</div><div> </div><div>Still the same logs.</div><div> </div><div>Eserica</div><div> </div></span><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new
roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <div class="hr" style="margin: 5px 0px; padding: 0px; border: 1px solid rgb(204, 204, 204); height: 0px; line-height: 0; font-size: 0px;" contenteditable="false" readonly="true"></div> <font face="Arial" size="2"> <b><span style="font-weight: bold;">From:</span></b> Alan McKinnon <alan.mckinnon@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> rancid shrubbery <rancid-discuss@shrubbery.net> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, September 16, 2013 4:33 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [rancid] Rancid-missed cmds<br> </font> </div> <div class="y_msg_container"><br>The approach to fixing this is always the same, at this point nothing<br>rancid is outputting helps debug in the slightest - all it says is that<br>something went wrong, but we already know that.<br><br>Do the following:<br><br>1. telnet to
device and check you can auth manually<br>2. "hulogin <device>" and check it logs in and enables properly, and<br>that the prompt etc on the screen is correct<br>3. run "hulogin -t 90 -c"display current-configuration,display version"<br><device>" and check that the commands do actually run correctly<br>4. run "hurancid -d <device>" - this dumps a *complete* log in the<br>current directory containing more info than the regular log you quoted<br>and often reveals the problem (but not always).<br><br><br>But first a few prior steps need to be verified:<br><br>- the command in #3 I pasted from your log output, and that has comma<br>separators. Your device might need semicolons, I have no idea as I don;t<br>know that vendors stuff<br>- the relevant line in router.db must contain the appropriate type<br>string in field 3<br>- you will have had to edit rancid-fe and add a line for huawei to a<br>perl hash. Without this, rancid-run doesn't
know what parser script to<br>call and it cannot work.<br>- the device you have must be supported by the script you are using;<br>just because Huawei made it is no guarantee it works similarly to<br>anything else they might have made.<br><br><br>If all of that checks out, then we need to look into the running perl<br>itself.<br><br>I believe we've been over most of this before, I don't recall getting a<br>definitive answer. You really do need to go through all these steps as<br>given, nothing else is going to get to the root of your problem.<br><br><br><br>On 16/09/2013 15:11, Erica James wrote:<br>> Hello<br>> I have a problem with rancid parsing script. Logs show missed cmd(s).<br>> Trying to get all of the configs.<br>> 10.3.4.5: missed cmd(s): display current-configuration,display version<br>> 10.3.4.5: End of run not found<br>> #<br>> All routers sucessfully completed.<br>> cvs diff: Diffing .<br>> cvs diff: Diffing
configs<br>> cvs commit: Examining .<br>> cvs commit: Examining configs<br>> <br>> The script is for Huawei. The problem now seems to be that rancid is not<br>> collecting configs.<br>> Anyone with an idea on what to do?<br>> <br>> Below is the rancid-script<br>> <br>> #! /usr/bin/perl<br>> ##<br>> ## $Id$<br>> ##<br>> ## rancid 2.3.8<br>> ##<br>> ## Copyright (C) 1997-2004 by Terrapin Communications, Inc.<br>> ## All rights reserved.<br>> ##<br>> ## This software may be freely copied, modified and redistributed<br>> ## without fee for non-commerical purposes provided that this license<br>> ## remains intact and unmodified with any RANCID distribution.<br>> ##<br>> ## There is no warranty or other guarantee of fitness of this software.<br>> ## It is provided solely "as is". The author(s) disclaim(s) all<br>> ## responsibility and liability with respect to
this software's usage<br>> ## or its effect upon hardware, computer systems, other software, or<br>> ## anything else.<br>> ##<br>> ## Except where noted otherwise, rancid was written by and is maintained by<br>> ## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin<br>> Schutz.<br>> ##<br>> #<br>> # hurancid - Interface to Huawei devices<br>> #<br>> # RANCID - Really Awesome New Cisco confIg Differ<br>> #<br>> # usage: rancid [-d] [-l] [-f filename | $host]<br>> #<br>> use Getopt::Std;<br>> getopts('dfl');<br>> $log = $opt_l;<br>> $debug = $opt_d;<br>> $file = $opt_f;<br>> $host = $ARGV[0];<br>> $clean_run = 0;<br>> $found_end = 0;<br>> $timeo = 90; # hulogin timeout in seconds<br>> <br>> my(%filter_pwds); # password filtering mode<br>>
# This routine is used to print out the router configuration<br>> sub ProcessHistory {<br>> my($new_hist_tag,$new_command,$command_string,@string)=(@_);<br>> if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))<br>> && defined %history) {<br>> print eval "$command \%history";<br>> undef %history;<br>> }<br>> if (($new_hist_tag) && ($new_command) && ($command_string)) {<br>> if ($history{$command_string}) {<br>> $history{$command_string} =<br>> "mailto:$history%7B$command_string%<a href="mailto:7D@string" ymailto="mailto:7D@string">7D@string</a>";<br>> } else {<br>> $history{$command_string} = "@string";<br>>
}<br>> } elsif (($new_hist_tag) && ($new_command)) {<br>> $history{++$#history} = "@string";<br>> } else {<br>> print "@string";<br>> }<br>> $hist_tag = $new_hist_tag;<br>> $command = $new_command;<br>> 1;<br>> }<br>> <br>> sub numerically { $a <=> $b; }<br>> <br>> # This is a sort routing that will sort numerically on the<br>> # keys of a hash as if it were a normal array.<br>> sub keynsort {<br>> local(%lines)=@_;<br>> local($i) = 0;<br>> local(@sorted_lines);<br>> foreach $key (sort numerically keys(%lines)) {<br>> $sorted_lines[$i] = $lines{$key};<br>> $i++;<br>> }<br>>
@sorted_lines;<br>> }<br>> <br>> # This is a sort routing that will sort on the<br>> # keys of a hash as if it were a normal array.<br>> sub keysort {<br>> local(%lines)=@_;<br>> local($i) = 0;<br>> local(@sorted_lines);<br>> foreach $key (sort keys(%lines)) {<br>> $sorted_lines[$i] = $lines{$key};<br>> $i++;<br>> }<br>> @sorted_lines;<br>> }<br>> <br>> # This is a sort routing that will sort on the<br>> # values of a hash as if it were a normal array.<br>> sub valsort{<br>> local(%lines)=@_;<br>> local($i) = 0;<br>> local(@sorted_lines);<br>> foreach $key (sort values %lines) {<br>> $sorted_lines[$i] = $key;<br>> $i++;<br>>
}<br>> @sorted_lines;<br>> }<br>> <br>> # This is a numerical sort routing (ascending).<br>> sub numsort {<br>> local(%lines)=@_;<br>> local($i) = 0;<br>> local(@sorted_lines);<br>> foreach $num (sort {$a <=> $b} keys %lines) {<br>> $sorted_lines[$i] = $lines{$num};<br>> $i++;<br>> }<br>> @sorted_lines;<br>> }<br>> <br>> # This is a sort routine that will sort on the<br>> # ip address when the ip address is anywhere in<br>> # the strings.<br>> sub ipsort {<br>> local(%lines)=@_;<br>> local($i) = 0;<br>> local(@sorted_lines);<br>> foreach $addr (sort sortbyipaddr keys %lines) {<br>> $sorted_lines[$i] = $lines{$addr};<br>>
$i++;<br>> }<br>> @sorted_lines;<br>> }<br>> <br>> # These two routines will sort based upon IP addresses<br>> sub ipaddrval {<br>> my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);<br>> $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));<br>> }<br>> sub sortbyipaddr {<br>> &ipaddrval($a) <=> &ipaddrval($b);<br>> }<br>> <br>> <br>> # This routine processes a "show configuration"<br>> # This routine processes a "show configuration"<br>> sub WriteTerm {<br>> print STDERR " In WriteTerm: $_" if ($debug);<br>> #my($lineauto) = 0;<br>> <br>> while (<INPUT>) {<br>> #print STDERR "History $_\n"; <br>> <br>> tr/\015//d;<br>> last
if(/^$prompt/);<br>> next if (/^(\s*|\s*$cmd\s*)$/);<br>> return(1) if (/^\s*\^\s*$/);<br>> return(1) if (/Line has invalid autocommand /);<br>> return(1) if (/(Invalid (input|command) detected|Type help or )/i);<br>> return(-1) if (/command authorization failed/i);<br>> # the pager can not be disabled per-session on the PIX<br>> if (/^(<-+ More -+>)/) {<br>> my($len) = length($1);<br>> s/^$1\s{$len}//;<br>> }<br>> <br>> /^/ && next;<br>> ProcessHistory("COMMENTS","keysort","B1","# $_") && next;<br>>
}<br>> <br>> # end of config...is a comment.<br>> if (/^return/i) {<br>> $found_end = 1;<br>> return(1);<br>> }<br>> <br>> return(0);<br>> }<br>> <br>> # This routine copies everything with precefing "#"<br>> sub CopyComment {<br>> print STDERR " In CopyComment: $_" if ($debug);<br>> <br>> while (<INPUT>) {<br>> tr/\015//d;<br>> last if (/^$prompt/);<br>> <br>> ProcessHistory("","","","# $_");<br>> # end of config<br>> }<br>> return(0);<br>> }<br>> <br>> # filter out "uptime" lines<br>> sub FilterUptime
{<br>> print STDERR " In FilterUptime: $_" if ($debug);<br>> <br>> while (<INPUT>) {<br>> tr/\015//d;<br>> last if (/^$prompt/);<br>> #nmeongeza<br>> next if (/^(\s*|\s*$cmd\s*)$/);<br>> return(-1) if (/command authorization failed/i);<br>> /^VERSION\=>(\s+.*)$/ &&<br>> ProcessHistory("COMMENTS","keysort","C1","\#\n# Version: $1\n")<br>> && next;<br>> /^PATCH\=>(\s+.*)$/ &&<br>> ProcessHistory("COMMENTS","keysort","C2","\# Patch: $1\n")<br>> && next;<br>> <br>> /^PRODUCT\=>(\s+.*)$/ &&<br>> ProcessHistory("COMMENTS","keysort","C3","\# Version: $1\n")<br>> && next;<br>> }<br>> return(0);<br>>
}<br>> <br>> <br>> # dummy function<br>> sub DoNothing {print STDOUT;}<br>> <br>> # Main<br>> @commandtable = (<br>> {'display version' => 'FilterUptime'},<br>> {'display patch-information' => 'CopyComment'},<br>> {'display device' => 'CopyComment'},<br>> {'display device pic-status' => 'CopyComment'},<br>> {'display current-configuration' => 'WriteTerm'},<br>> );<br>> <br>> # Use an array to preserve the order of the commands and a hash for mapping<br>> # commands to the
subroutine and track commands that have been completed.<br>> @commands = map(keys(%$_), @commandtable);<br>> %commands = map(%$_, @commandtable);<br>> <br>> $huaw_cmds=join(";",@commands);<br>> $cmds_regexp=join("|",@commands);<br>> <br>> open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";<br>> select(OUTPUT);<br>> # make OUTPUT unbuffered if debugging<br>> if ($debug) { $| = 1; }<br>> <br>> if ($file) {<br>> print STDERR "opening file $host\n" if ($debug);<br>> print STDOUT "opening file $host\n" if ($log);<br>> open(INPUT,"<$host") || die "open failed for $host: $!\n";<br>> } else {<br>> print STDERR "executing hulogin -t $timeo -c\"$huaw_cmds\" $host\n"<br>> if ($debug);<br>> print STDOUT "executing hulogin -t $timeo -c\"$huaw_cmds\" $host\n"<br>> if ($debug);<br>> if
(defined($ENV{NOPIPE}) && $ENV{NOPIPE} =~ /^YES/i) {<br>> system "hulogin -t $timeo -c \"$huaw_cmds\" $host </dev/null ><br>> $host.raw" || die "hulogin failed for $host: $!\n";<br>> open(INPUT, "< $host.raw") || die "hulogin failed for $host: $!\n";<br>> } else {<br>> open(INPUT,"hulogin -t $timeo -c \"$huaw_cmds\" $host </dev/null<br>> |") || die "hulogin failed for $host: $!\n";<br>> }<br>> }<br>> <br>> # determine password filtering mode<br>> if ($ENV{"FILTER_PWDS"} =~ /no/i) {<br>> $filter_pwds = 0;<br>> } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {<br>> $filter_pwds = 2;<br>> } else {<br>> $filter_pwds = 1;<br>> }<br>> <br>> ProcessHistory("","","","#RANCID-CONTENT-TYPE:
Huawei\n#\n");<br>> ProcessHistory("COMMENTS","keysort","B0","#\n");<br>> ProcessHistory("COMMENTS","keysort","F0","#\n");<br>> ProcessHistory("COMMENTS","keysort","G0","#\n");<br>> TOP: while(<INPUT>) {<br>> tr/\015//d;<br>> <br>> #print STDERR ("CMD: $_\n"); <br>> <br>> if (/\>\s?quit.*$/) {<br>> $clean_run=1;<br>> last;<br>> }<br>> <br>> if (/^Error:/) {<br>> print STDOUT ("$host hulogin error: $_");<br>> print STDERR ("$host hulogin error: $_") if ($debug);<br>> $clean_run=0;<br>> last;<br>> }<br>> <br>> while (/\>\007*\s*($cmds_regexp)\s*$/) {<br>> $cmd = $1;<br>>
<br>> if (!defined($prompt)) {<br>> $prompt = ($_ =~ /^([^>]+\>)/)[0];<br>> $prompt =~ s/([][}{)(file://])///$1/g;<br>> print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);<br>> }<br>> print STDERR ("HIT COMMAND:$_") if ($debug);<br>> if (! defined($commands{$cmd})) {<br>> print STDERR "$host: found unexpected command - \"$cmd\"\n";<br>> $clean_run = 0;<br>> last TOP;<br>> }<br>> $rval = &{$commands{$cmd}};<br>> delete($commands{$cmd});<br>>
if ($rval == -1) {<br>> $clean_run = 0;<br>> last TOP;<br>> }<br>> }<br>> }<br>> print STDOUT "Done $logincmd: $_\n" if ($log);<br>> # Flush History<br>> ProcessHistory("","","","");<br>> # Cleanup<br>> close(INPUT);<br>> close(OUTPUT);<br>> <br>> if (defined($ENV{NOPIPE})) {<br>> #unlink("$host.raw") if (! $debug);<br>> }<br>> # check for completeness<br>> if (scalar(%commands) || !$clean_run || !$found_end) {<br>> if (scalar(%commands)) {<br>> printf(STDOUT "$host: missed cmd(s): %s\n", join(',',<br>> keys(%commands)));<br>> printf(STDERR "$host: missed cmd(s): %s\n", join(',',<br>> keys(%commands))) if ($debug);<br>> }<br>> if
(!$clean_run || !$found_end) {<br>> print STDOUT "$host: End of run not found\n";<br>> print STDERR "$host: End of run not found\n" if ($debug);<br>> system("/usr/bin/tail -1 $host.new");<br>> }<br>> #unlink "$host.new" if (! $debug);<br>> }<br>> <br>> <br><br><br>-- <br>Alan McKinnon<br><a href="mailto:alan.mckinnon@gmail.com" ymailto="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a><br><br>_______________________________________________<br>Rancid-discuss mailing list<br><a href="mailto:Rancid-discuss@shrubbery.net" ymailto="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br><a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br><br><br></div> </div> </div> </div></body></html>