#!/bin/csh -f # nomagats # ----------------------------------------------------------------------------- # C shell script to merge the specified mailing lists, echoing a union of # all lines from all lists, but subtracting those lines that exist in the # MAGAts and potential MAGAts lists, and those who've explicitly asked to # get no political email. # ----------------------------------------------------------------------------- # Usage: See Usage section below or run with -h or --help to see usage. # Assumptions: # Effects: # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ----------------------------------------------------------------------------- # Collect command line options set option_ignore_case = "false" set option_all = "false" while ($#argv > 0) if ("$1:q" == "-h" || "$1:q" == "--help") then echo "Usage: $0:t [options] mailing_list_file..." echo "Options:" echo " -h = Show this help info" echo " --help = Show this help info" exit 1 else if ("-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0:t --help exit 1 else # Not a recognized option. Assume it's the first parameter break endif end set timestamp = `date "+%Y_%m_%d__%H_%M_%S"` set tempfile1 = "/tmp/$0:t_$$_file1_$timestamp" set tempfile2 = "/tmp/$0:t_$$_file2_$timestamp" set unionfile = "/tmp/$0:t_$$_union_$timestamp" set subtractfile = "/tmp/$0:t_$$_subtract_$timestamp" cd ~/fred/Mozilla/TBird/lists # Build merged mailing list touch $tempfile1:q while ($#argv > 0) set listname = $1:q shift if (! -e $listname:q) then set listname = "${listname}.lis" endif if (! -e $listname:q) then beep "Error: File $listname does not exist." rm -f $tempfile1:q rm -f $tempfile2:q exit 1 endif union -i $listname:q $tempfile1:q > $tempfile2:q mv $tempfile2:q $tempfile1:q end mv $tempfile1:q $unionfile:q # Build merged subtract list touch $tempfile1:q foreach listname ( \ TrumpYes_NoSpam \ TrumpYes \ TrumpDontCare \ VoteNoSpam \ HHNHH_nospam \ TrumpNo_NoSpam \ ) if (! -e $listname:q) then set listname = "${listname}.lis" endif if (! -e $listname:q) then beep "Error: File $listname does not exist." rm -f $tempfile1:q rm -f $tempfile2:q rm -f $unionfile:q exit 1 endif union -i $listname:q $tempfile1:q > $tempfile2:q mv $tempfile2:q $tempfile1:q end mv $tempfile1:q $subtractfile:q # Subtract from the merged list subtract -i $unionfile:q $subtractfile:q # Cleanuo rm -f $tempfile1:q rm -f $tempfile2:q rm -f $unionfile:q rm -f $subtractfile:q