Whitespace after ":up" in router.db
john heasley
heas at shrubbery.net
Wed Dec 10 01:55:53 UTC 2003
Tue, Dec 09, 2003 at 11:39:45AM +0100, Alastair Galloway:
> Hi all,
>
> I've just started using RANCID 2.3 EFT (cheers to John for that) along with
> a rivlogin from Andrew Fort (based on rscmd, which was based on clogin). I
> found that a space after the ":up" in a router.db file resulted in that
> device being read as down. Andrew pointed out that the problem was in
> bin/control_rancid and that the two instances of the /^up$/ regexp would
> need to be replaced with /^up\s*$/ to match "up" and then any amount of
> whitespace after it. That's fixed the problem for me, so I'm sharing it
> with everyone else here:
>
> [rancid]$ diff bin/control_rancid~ bin/control_rancid
> 139c139
> < if ($F[2] !~ /^up$/i);}' routers.db | sort -u > routers.down.new
> ---
> > if ($F[2] !~ /^up\s*$/i);}' routers.db | sort -u > routers.down.new
> 143c143
> < if ($F[2] =~ /^up$/i);}' routers.db | sort -u > routers.up.new
> ---
> > if ($F[2] =~ /^up\s*$/i);}' routers.db | sort -u > routers.up.new
Thanks. This might make this just a bit more general.
Index: control_rancid.in
===================================================================
RCS file: /home/rancid/.CVS/rancid/bin/control_rancid.in,v
retrieving revision 1.52
diff -u -d -u -r1.52 control_rancid.in
--- control_rancid.in 26 Nov 2003 19:48:20 -0000 1.52
+++ control_rancid.in 10 Dec 2003 01:37:02 -0000
@@ -131,16 +131,17 @@
cd $DIR
trap 'rm -fr routers.db routers.all.new routers.down.new routers.up.new \
routers.mail routers.added routers.deleted $TMP;' 1 2 15
-grep -v '^#' router.db > routers.db
-cut -d: -f1,2 routers.db | sort -u > routers.all.new
+sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
+ sort -u > routers.db
+cut -d: -f1,2 routers.db > routers.all.new
if [ ! -f routers.all ] ; then touch routers.all; fi
diff routers.all routers.all.new > /dev/null 2>&1; RALL=$?
@PERLV@ -F: -ane '{($F[0] =~ tr at A-Z@a-z@,print $_)
- if ($F[2] !~ /^up$/i);}' routers.db | sort -u > routers.down.new
+ if ($F[2] !~ /^up$/i);}' routers.db > routers.down.new
if [ ! -f routers.down ] ; then touch routers.down; fi
diff routers.down routers.down.new > /dev/null 2>&1; RDOWN=$?
@PERLV@ -F: -ane '{($F[0] =~ tr at A-Z@a-z@,print "$F[0]:$F[1]\n")
- if ($F[2] =~ /^up$/i);}' routers.db | sort -u > routers.up.new
+ if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
if [ ! -f routers.up ] ; then touch routers.up; fi
diff routers.up routers.up.new > /dev/null 2>&1; RUP=$?
More information about the Rancid-discuss
mailing list