checkzone from stdin?

Grant Taylor gtaylor at tnetconsulting.net
Wed Apr 8 20:22:56 UTC 2020


On 4/8/20 1:55 PM, Anand Buddhdev wrote:
> named-checkzone wants a file, so give it a "file":
> 
> named-checkzone ripe.net. /dev/stdin < ripe.net.zone

You might also consider <(...) files.

    named-checkzone example.com <(cat example.com.db)

> Note that it would work with "cat file | ..." but I absolutely hate 
> the cat-pipe combination. I've been known to mark down interviewees 
> who offer a solution that involves cats and pipes :)

Is cat superfulous, probably.  But I'm quite willing to overlook the 
useless use of cat if it's a junior admin who's still learning about 
stringing commands together.

I'll give a nod of approval if someone says something to the effect of:

    Yes, I can remove cat and redirect in from the file, but that 
changes the command, slightly, from what would be used elsewhere. 
Seeing how cat tempfile is a stand in for a larger more resource 
intensive purpose....

I digress.

> If you want to feed a compressed zone file, then of course a 
> gzcat-pipe combination will work, eg:
> 
> gzcat ripe.net.zone.gz | named-checkzone ripe.net. /dev/stdin

    named-checkzone ripe.net. <(gzcat ripe.net.zone.gz)

> Finally, if you're running your scripts under bash, then bash offers 
> a very neat feature:

More than just Bash supports it.

I've been using it in Zsh for years.  And bash for years before switching.

> named-checkzone ripe.net. <(gzcat ripe.net.zone.gz)
> 
> The "<(...)" construct in bash runs the command inside the parantheses,
> and sends its output to an ephemeral file of the form /dev/fd/42. So the
> above command becomes:
> 
> named-checkzone ripe.net. /dev/fd/42
> 
> and named-checkzone reads the "file" /dev/fd/42, getting the
> decompressed data.

Thank you for the detailed explanation.



-- 
Grant. . . .
unix || die

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4013 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20200408/b97f9763/attachment.bin>


More information about the bind-users mailing list