<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>Thanks Alan for the tip.</div>
<div><br>
</div>
<div>I used regexr.com to help with this. Man, I wish this site was around 10 years ago when I was writing regexps on a daily basis. I had forgotten most of it.</div>
<div><br>
</div>
<div>This looks like it will work just fine:</div>
<div><br>
</div>
<div> s/^\ \ ([0-9]+)(\ +)(.*up.*)\ +([0-9]+) /$1$2$3REMOVEDRPM/i;</div>
<div><br>
</div>
<div>Thanks, Matt</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Alan McKinnon <<a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, July 8, 2015 at 12:11 AM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:rancid-discuss@shrubbery.net">rancid-discuss@shrubbery.net</a>" <<a href="mailto:rancid-discuss@shrubbery.net">rancid-discuss@shrubbery.net</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [rancid] How to remove fan speed from f5rancid output?<br>
</div>
<div><br>
</div>
<div>
<div>
<div>On 08/07/2015 01:14, Matt Almgren wrote:</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>Well, I had thought I had fixed this, but it was just not running for</div>
<div>our f5s for a while. Oopps.</div>
<div></div>
<div>Anyway, my perl-fu isn’t very good. Can someone quickly tell me what I</div>
<div>need to change in this code to remove the fan speed(rpm) values from the</div>
<div>output below:</div>
<div></div>
<div></div>
<div>## $Id: f5rancid.in 2279 2011-01-31 22:41:00Z heas $</div>
<div></div>
<div>sub ShowHardware {</div>
<div> print STDERR " In ShowHardware: $_" if ($debug);</div>
<div></div>
<div> while (<INPUT>) {</div>
<div> tr/\015//d;</div>
<div> last if (/^$prompt/);</div>
<div> next if (/^(\s*|\s*$cmd\s*)$/);</div>
<div> return(1) if /^\s*\^\s*$/;</div>
<div> return(1) if /(Invalid input detected|Type help or )/;</div>
<div> return(-1) if (/command authorization failed/i);</div>
<div></div>
<div> s/\d+rpm//ig;</div>
<div> s/^\|//;</div>
<div> s/^\ \ ([0-9]+)(\ +).*up.*[0-9]/ $1$2up REMOVED/i;</div>
</blockquote>
<div> ^^^^ ^^</div>
<div><br>
</div>
<div>This is the code that is intended to do what you want.</div>
<div>But there's no need to escape the spaces in that regex.</div>
<div>Replace with literal spaces, or preferrably \s for any whitespace:</div>
<div><br>
</div>
<div> s/^\s+([0-9]+)(\s+).*up.*[0-9]/ $1$2up REMOVED/i;</div>
<div><br>
</div>
<div><br>
</div>
<div>Tweak and adjust it to your liking depending on what you want the output</div>
<div>line to be transformed into.</div>
<div><br>
</div>
<div>You don't need much perl-fu for this, you do however need quite a bit of</div>
<div>regex-fu. The Llama Book (google it) has very good perl regex tutorials</div>
<div>at just the right level to get you going.</div>
<div><br>
</div>
<div><br>
</div>
<div>Alan</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>-- </div>
<div>Alan McKinnon</div>
<div><a href="mailto:alan.mckinnon@gmail.com">alan.mckinnon@gmail.com</a></div>
<div><br>
</div>
<div>_______________________________________________</div>
<div>Rancid-discuss mailing list</div>
<div><a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a></div>
<div><a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a></div>
<div><br>
</div>
</div>
</div>
</span>
</body>
</html>