Help scripting dns lookup using awk

Polytropon freebsd at edvax.de
Sat Sep 16 14:20:14 UTC 2017


On Fri, 15 Sep 2017 19:20:22 -0400, Ernie Luzar wrote:
> RW via freebsd-questions wrote:
> > On Thu, 14 Sep 2017 20:55:00 -0400
> > Ernie Luzar wrote:
> > 
> >> The following sh script works, but runs very slow.
> > 
> > Almost certainly the reason it's slow is that you are doing sequential
> > synchronous lookups. Switching  to another language isn't going help
> > much. To speed it up you either need to switch to a language with a
> > DNS library that supports asynchronous lookups or fire-off parallel
> > child processes. The latter is easier.
> > 
> 
> How would I go about coding a sh script to fire-off parallel child 
> processes?

There are several methods. One would be to "pre-sort" per TLD
or per IP. You can do this with awk or a sort | grep contruct.
Then you iterate over the result files and send the batch lookup
processes into background with the & appended. When everything
is done, re-combine the result files as needed.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list