I've been running a script to extract Exchange mail recipient addresses and update my local postfix relay_recipients table for years. Script comes from The Book of Postfix, has worked flawlessly until now.
The key line that is causing issues still works fine on one server, but gives me an empty result on the other.
cat /home/username/mailrecipients.txt extra_recipients | tr -d \" | tr , \\n | tr \; \\n | tr -d '\r' | awk -F\: '/(SMTP|smtp):/ {printf("%s\tOK\n",$2)}' | grep -vi --file=blacklist
The script combines some hardcoded addresses with the mail recipients files, strips out unneeded stuff, and generates a long list of email addresses with an OK and newline. Everything works perfectly up to the grep. On one server, piping the output to grep with inverse match of the patterns contained in blacklist file strips out the addresses I don't want and returns the rest correctly. On the other server, with the same version of grep, I get an empty result. The three files (blacklist, mailrecipients.txt, and extra_recipients) are identical on both servers.
Any ideas on what's happening here?
EDIT: Output of the awk command before grep:
email1@mycompany.com OK
email2@mycompany.com OK
email3@mycompany.com OK
restricted@mycompany.com OK
blacklist file: restricted
Expected result:
email1@mycompany.com OK
email2@mycompany.com OK
email3@mycompany.com OK
One server returns this correctly, and the other server returns an empty set.