Discussion:
[rancid] modifying diff conditions
Wayne Eisenberg
2013-11-15 12:17:04 UTC
Permalink
Maybe, maybe not. I've tried your format, too, and it isn't working.
'(term1|term2|term3)'
'(.*term1.*|.*term2.*|.*term.*)' - (might be overkill, but thought I would try it).

Funny thing, if I run the 'cvs -f diff' command at the command prompt, then it ignores the appropriate lines.

cvs -f diff -r 1.150 -r 1.151 -U 4 -ko --ignore-matching-lines=___________

but within the script it doesn't behave the same. What's different (besides that I have to specify which revisions to diff)?


-----Original Message-----
From: heasley [mailto:***@shrubbery.net]
Sent: Friday, November 08, 2013 12:21 PM
To: Wayne Eisenberg
Cc: 'rancid-***@shrubbery.net'
Subject: Re: [rancid] modifying diff conditions
Well, I've done some experimenting and I think I've seen that the
regex expression doesn't always work. I found that --ignore-matching-lines='av\|wildfire\|threat'
*can* work, but if I don't include all of the things to ignore, it
won't ignore any of them. For example, with the text below, 'av\|wildfire\|url-filtering\|app\|threat' will successfully ignore all of those lines. But if I omit one of the elements (say 'threat'), it won't ignore any of the lines even though I would expect it to only return the 'threat' lines as different. Does anyone have any ideas or explanation of this behavior?
bad RE format, i suspect. '(term1|term2|term3)'

i do not know if any of those chars needs to be escaped, since its in single quotes. but, depends on how cvs execs diff.

The information in this Internet e-mail (and any attachments) is confidential, may be legally privileged and is intended solely for the Addressee(s) named above. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, then any dissemination or copying of this e-mail (and any attachments) is prohibited and may be unlawful. If you received this e-mail in error, please immediately notify us by e-mail or telephone, then delete the message. Thank you.
'heasley'
2013-11-15 16:37:28 UTC
Permalink
Post by Wayne Eisenberg
Maybe, maybe not. I've tried your format, too, and it isn't working.
| or \| without the grouping operator is a |; so I believe that I am correct.
Post by Wayne Eisenberg
'(term1|term2|term3)'
'(.*term1.*|.*term2.*|.*term.*)' - (might be overkill, but thought I would try it).
Funny thing, if I run the 'cvs -f diff' command at the command prompt, then it ignores the appropriate lines.
cvs -f diff -r 1.150 -r 1.151 -U 4 -ko --ignore-matching-lines=___________
try it with '(term1|term2|term3)'
Post by Wayne Eisenberg
but within the script it doesn't behave the same. What's different (besides that I have to specify which revisions to diff)?
possibly the quoting. have you altered the cvs diff line itself, or use a
variable on that line? for example, .* being glob expanded. or possibly the
version of diff that you are getting as a result of differences in PATH?
Post by Wayne Eisenberg
-----Original Message-----
Sent: Friday, November 08, 2013 12:21 PM
To: Wayne Eisenberg
Subject: Re: [rancid] modifying diff conditions
Well, I've done some experimenting and I think I've seen that the
regex expression doesn't always work. I found that --ignore-matching-lines='av\|wildfire\|threat'
*can* work, but if I don't include all of the things to ignore, it
won't ignore any of them. For example, with the text below, 'av\|wildfire\|url-filtering\|app\|threat' will successfully ignore all of those lines. But if I omit one of the elements (say 'threat'), it won't ignore any of the lines even though I would expect it to only return the 'threat' lines as different. Does anyone have any ideas or explanation of this behavior?
bad RE format, i suspect. '(term1|term2|term3)'
i do not know if any of those chars needs to be escaped, since its in single quotes. but, depends on how cvs execs diff.
The information in this Internet e-mail (and any attachments) is confidential, may be legally privileged and is intended solely for the Addressee(s) named above. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, then any dissemination or copying of this e-mail (and any attachments) is prohibited and may be unlawful. If you received this e-mail in error, please immediately notify us by e-mail or telephone, then delete the message. Thank you.
Wayne Eisenberg
2013-11-19 21:07:38 UTC
Permalink
I've already tried '(term1|term2|term3)', no joy.

I haven't altered the cvs diff line itself other than adding in --ignore-matching-lines. I modified bin/control_rancid from:

if [ $RCSSYS = "cvs" ] ; then
cvs -f diff -U 4 -ko | sed -e '/^RCS file: /d' -e '/^--- /d' \
-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff

to:

if [ $RCSSYS = "cvs" ] ; then
cvs -f diff -U 4 -ko --ignore-matching-lines='(.*av-.*|.*wildfire-.*|.*threat-.*|.*url-filtering-.*|.*app-.*|.*call-forwarding.*)' | sed -e '/^RCS file: /d' -e '/^--- /d' \ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff

when I run it interactively on the command line, I go to the /usr/local/rancid/var/<group>/configs/ directory and run

cvs -f diff -r 1.150 -r 1.151 -U 4 -ko --ignore-matching-lines='(term1|term2|term3)'

so that it will do the comparison. It works then, but not within the script itself.

Should I try double quotes instead of single quotes? I don't have a lot of ideas at this point.

There's only one copy of diff on the system in /usr/bin.

-----Original Message-----
Post by Wayne Eisenberg
Maybe, maybe not. I've tried your format, too, and it isn't working.
| or \| without the grouping operator is a |; so I believe that I am correct.
Post by Wayne Eisenberg
'(term1|term2|term3)'
'(.*term1.*|.*term2.*|.*term.*)' - (might be overkill, but thought I would try it).
Funny thing, if I run the 'cvs -f diff' command at the command prompt, then it ignores the appropriate lines.
cvs -f diff -r 1.150 -r 1.151 -U 4 -ko
--ignore-matching-lines=___________
try it with '(term1|term2|term3)'
Post by Wayne Eisenberg
but within the script it doesn't behave the same. What's different (besides that I have to specify which revisions to diff)?
possibly the quoting. have you altered the cvs diff line itself, or use a variable on that line? for example, .* being glob expanded. or possibly the version of diff that you are getting as a result of differences in PATH?
Post by Wayne Eisenberg
-----Original Message-----
Sent: Friday, November 08, 2013 12:21 PM
To: Wayne Eisenberg
Subject: Re: [rancid] modifying diff conditions
Well, I've done some experimenting and I think I've seen that the
regex expression doesn't always work. I found that --ignore-matching-lines='av\|wildfire\|threat'
*can* work, but if I don't include all of the things to ignore, it
won't ignore any of them. For example, with the text below, 'av\|wildfire\|url-filtering\|app\|threat' will successfully ignore all of those lines. But if I omit one of the elements (say 'threat'), it won't ignore any of the lines even though I would expect it to only return the 'threat' lines as different. Does anyone have any ideas or explanation of this behavior?
bad RE format, i suspect. '(term1|term2|term3)'
i do not know if any of those chars needs to be escaped, since its in single quotes. but, depends on how cvs execs diff.
The information in this Internet e-mail (and any attachments) is confidential, may be legally privileged and is intended solely for the Addressee(s) named above. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, then any dissemination or copying of this e-mail (and any attachments) is prohibited and may be unlawful. If you received this e-mail in error, please immediately notify us by e-mail or telephone, then delete the message. Thank you.
'heasley'
2013-11-22 00:26:30 UTC
Permalink
Post by Wayne Eisenberg
if [ $RCSSYS = "cvs" ] ; then
cvs -f diff -U 4 -ko --ignore-matching-lines='(.*av-.*|.*wildfire-.*|.*threat-.*|.*url-filtering-.*|.*app-.*|.*call-forwarding.*)' | sed -e '/^RCS file: /d' -e '/^--- /d' \ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
I messed around with this option a bit. what i've discovered is that
1) is doesnt accept extended regexps
2) it does allow the option to appear more than once, or at least twice
3) http://www.delorie.com/gnu/docs/cvs/cvs_130.html implies that it will
only work for changes that affect one line. ie:
--ignore-matching-lines='foo'
Post by Wayne Eisenberg
interface foo
description foo to spamalot
4) it does not appear to appear to work with -U

YFMV (your frustration may vary).
Wayne Eisenberg
2013-11-22 10:39:24 UTC
Permalink
OK, I wasn't off too much but I didn't trust my results due to my non-mastery in the linux world. The only other way I can see making this work is to leave the cvs diff alone, and modify the rancid script itself. This is a PaloAlto device, so it's actually a script called panlong. Here's the section :

# This routine parses "show system info"
sub ShowInfo {
my($slot);

print STDERR " In ShowInfo:: $_" if ($debug);

while (<INPUT>) {
tr/\015//d;
next if /^\s*$/;
last if (/^$prompt/);

next if (/^(time:|uptime:)/);

ProcessHistory("INFO","","","#$_");
}
ProcessHistory("INFO","","","#\n");
return(0);
}

If I add a line 'next if (/^(wildfire|av)/);' in the "while (<INPUT>)" section, that ought to skip retrieving those lines. If they're not retrieved, they can't be diff'ed, right?


-----Original Message-----
From: 'heasley' [mailto:***@shrubbery.net]
Sent: Thursday, November 21, 2013 7:27 PM
To: Wayne Eisenberg
Cc: 'heasley'; 'rancid-***@shrubbery.net'
Subject: Re: [rancid] modifying diff conditions
Post by Wayne Eisenberg
if [ $RCSSYS = "cvs" ] ; then
cvs -f diff -U 4 -ko --ignore-matching-lines='(.*av-.*|.*wildfire-.*|.*threat-.*|.*url-filtering-.*|.*app-.*|.*call-forwarding.*)' | sed -e '/^RCS file: /d' -e '/^--- /d' \ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
I messed around with this option a bit. what i've discovered is that
1) is doesnt accept extended regexps
2) it does allow the option to appear more than once, or at least twice
3) http://www.delorie.com/gnu/docs/cvs/cvs_130.html implies that it will
only work for changes that affect one line. ie:
--ignore-matching-lines='foo'
Post by Wayne Eisenberg
interface foo
description foo to spamalot
4) it does not appear to appear to work with -U

YFMV (your frustration may vary).

________________________________

The information in this Internet e-mail (and any attachments) is confidential, may be legally privileged and is intended solely for the Addressee(s) named above. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, then any dissemination or copying of this e-mail (and any attachments) is prohibited and may be unlawful. If you received this e-mail in error, please immediately notify us by e-mail or telephone, then delete the message. Thank you.
Wayne Eisenberg
2013-11-22 10:44:27 UTC
Permalink
That should have been 'panrancid', not 'panlong'. (where did *that* come from?)

-----Original Message-----
From: rancid-discuss-***@shrubbery.net [mailto:rancid-discuss-***@shrubbery.net] On Behalf Of Wayne Eisenberg
Sent: Friday, November 22, 2013 5:39 AM
To: 'heasley'
Cc: 'rancid-***@shrubbery.net'
Subject: Re: [rancid] modifying diff conditions

OK, I wasn't off too much but I didn't trust my results due to my non-mastery in the linux world. The only other way I can see making this work is to leave the cvs diff alone, and modify the rancid script itself. This is a PaloAlto device, so it's actually a script called panlong. Here's the section :

# This routine parses "show system info"
sub ShowInfo {
my($slot);

print STDERR " In ShowInfo:: $_" if ($debug);

while (<INPUT>) {
tr/\015//d;
next if /^\s*$/;
last if (/^$prompt/);

next if (/^(time:|uptime:)/);

ProcessHistory("INFO","","","#$_");
}
ProcessHistory("INFO","","","#\n");
return(0);
}

If I add a line 'next if (/^(wildfire|av)/);' in the "while (<INPUT>)" section, that ought to skip retrieving those lines. If they're not retrieved, they can't be diff'ed, right?


-----Original Message-----
From: 'heasley' [mailto:***@shrubbery.net]
Sent: Thursday, November 21, 2013 7:27 PM
To: Wayne Eisenberg
Cc: 'heasley'; 'rancid-***@shrubbery.net'
Subject: Re: [rancid] modifying diff conditions
Post by Wayne Eisenberg
if [ $RCSSYS = "cvs" ] ; then
cvs -f diff -U 4 -ko --ignore-matching-lines='(.*av-.*|.*wildfire-.*|.*threat-.*|.*url-filtering-.*|.*app-.*|.*call-forwarding.*)' | sed -e '/^RCS file: /d' -e '/^--- /d' \ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
I messed around with this option a bit. what i've discovered is that
1) is doesnt accept extended regexps
2) it does allow the option to appear more than once, or at least twice
3) http://www.delorie.com/gnu/docs/cvs/cvs_130.html implies that it will
only work for changes that affect one line. ie:
--ignore-matching-lines='foo'
Post by Wayne Eisenberg
interface foo
description foo to spamalot
4) it does not appear to appear to work with -U

YFMV (your frustration may vary).

________________________________

The information in this Internet e-mail (and any attachments) is confidential, may be legally privileged and is intended solely for the Addressee(s) named above. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, then any dissemination or copying of this e-mail (and any attachments) is prohibited and may be unlawful. If you received this e-mail in error, please immediately notify us by e-mail or telephone, then delete the message. Thank you.
'heasley'
2013-11-22 21:29:30 UTC
Permalink
Post by Wayne Eisenberg
# This routine parses "show system info"
sub ShowInfo {
my($slot);
print STDERR " In ShowInfo:: $_" if ($debug);
while (<INPUT>) {
tr/\015//d;
next if /^\s*$/;
last if (/^$prompt/);
next if (/^(time:|uptime:)/);
ProcessHistory("INFO","","","#$_");
}
ProcessHistory("INFO","","","#\n");
return(0);
}
If I add a line 'next if (/^(wildfire|av)/);' in the "while (<INPUT>)" section, that ought to skip retrieving those lines. If they're not retrieved, they can't be diff'ed, right?
correct.

Loading...