in reply to Re: Loop problem: jumps one record
in thread Loop problem: jumps one record

Yes indeed I'm trying to read from pflogsumm's output. The purpose is to read addresses from it and add them to a local database.

Replies are listed 'Best First'.
Re^3: Loop problem: jumps one record
by hippo (Archbishop) on Jan 31, 2017 at 13:43 UTC

    In that case there is a limited number of approaches which you could take to this. I can immediately think of these three.

    1. Use your current strategy to parse the pflogsumm output. This means that you can leverage the options to pflogsumm to help you structure the data in the most useful way to you. Be aware that it is prone to breakage if the output format ever changes.
    2. Modify (a copy of) pflogsumm so that it either outputs precisely what you want or even performs the whole task for you including the database insertion. pflogsumm is written in Perl which makes this option less daunting that it would otherwise be.
    3. Ignore pflogsumm and read the mail log directly. There is Mail::Log::Parse::Postfix which might help with this (I've not used it so YMMV).

    Good luck with your project.