Re: [PLUG] Help with email scripts...
Take a look at RFC 1342: https://tools.ietf.org/html/rfc1342 From that: - An "encoded-word" is a sequence of printable ASCII characters that begins with "=?", ends with "?=", and has two "?"s in between. - Not sure if you just want to toss these away or what. But you might want to possibly try something like this: #!/bin/bash $file = "/your_subject.txt" # if RFC1341 discard if [ ! `grep -q '^Subject: =?' mailfile` ] then grep '^Subject: >> $file fi Kevin On Sun, 23 Jun 2019, Michael Christopher Robinson wrote: On Sun, 2019-06-23 at 17:54 -0500, Michael Christopher Robinson wrote: I am having trouble using grep to grab subject lines from my spam folder on eskimo. Some of the subject lines are unintelligible because they are utf8xxx and are probably part of a larger html message. Is there a slick way to get the subject line without reading the whole entire message in an html browser? Attached are two scripts. The spam_dump.bash script is supposed to dump the spam folder and be used once a week. I wonder if the gurus here can take a look and see if I can do this better? The spam_check.bash script is supposed to grep the subject lines o, so I came up with an idea of fetching just a subject list of messages in a spam folder and automating the dumping of that spam folder. -- Michael C. Robinson [michael@eagle ~]$ cat spam_check.bash #!/bin/bash cd ~/mail cat spam|grep 'Subject: ' > spam_subjects mail -s "Spam subject list" ad...@robinson-west.com < spam_subjects rm -f spam_subjects [michael@eagle ~]$ [michael@eagle ~]$ cat spam_dump.bash #!/bin/bash # # Launch from crontab once a week at midnight. # # Snapshot current spam folder. # Dump spam folder by copying over it empty spam mbox. cd ~ # Figure out how many backups there are. count=`cat archive_spam/count` # Dump the backups after four back ups. if [ "$count" -gt "4" ] then # Store a list of what is in archive_spam directory for emailing... ls -l archive_spam > file_list # Email to admin what is being dumped, file list in body... mail -s "Dump last four weeks of spam" ad...@robinson-west.com < file_list if [ ! -d ~/archive_spam/hold ] then mkdir ~/archive_spam/hold fi # Get a listing of the spam subjects... ./spam_check.bash # Move the backups into hold... mv -vf archive_spam/spam_mbox.* archive_spam/hold/ # Dump the 4 weeks of backups of spam mboxes... rm -vf archive_spam/spam_mbox.* # Set count back to 1... let count=1 fi diff mail/spam archive_spam/spam_template_mbox spam_empty=$? # Save this spam mbox unless it is empty... if [ ! $spam_empty ] then # Backup the current spam folder... cp mail/spam archive_spam/spam_mbox.$count # Copy over spam folder empty spam folder... cp -f archive_spam/spam_template_mbox mail/spam # Increment the backups counter... let count="$count + 1" else mail -s "The spam folder was empty at dump time!" ad...@robinson-west.com < archive_spam/count ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Help with email scripts...
On Sun, 2019-06-23 at 17:54 -0500, Michael Christopher Robinson wrote: > I am having trouble using grep to grab subject lines from my spam > folder on eskimo. Some of the subject lines are unintelligible > because > they are utf8xxx and are probably part of a larger html message. > Is there a slick way to get the subject line without reading the > whole > entire message in an html browser? > > Attached are two scripts. The spam_dump.bash script is supposed to > dump the spam folder and be used once a week. I wonder if the gurus > here can take a look and see if I can do this better? The > spam_check.bash script is supposed to grep the subject lines o, so I came > up with an idea of fetching just a subject list of messages in a spam > folder and automating the dumping of that spam folder. > > -- Michael C. Robinson [michael@eagle ~]$ cat spam_check.bash #!/bin/bash cd ~/mail cat spam|grep 'Subject: ' > spam_subjects mail -s "Spam subject list" ad...@robinson-west.com < spam_subjects rm -f spam_subjects [michael@eagle ~]$ [michael@eagle ~]$ cat spam_dump.bash #!/bin/bash # # Launch from crontab once a week at midnight. # # Snapshot current spam folder. # Dump spam folder by copying over it empty spam mbox. cd ~ # Figure out how many backups there are. count=`cat archive_spam/count` # Dump the backups after four back ups. if [ "$count" -gt "4" ] then # Store a list of what is in archive_spam directory for emailing... ls -l archive_spam > file_list # Email to admin what is being dumped, file list in body... mail -s "Dump last four weeks of spam" ad...@robinson-west.com < file_list if [ ! -d ~/archive_spam/hold ] then mkdir ~/archive_spam/hold fi # Get a listing of the spam subjects... ./spam_check.bash # Move the backups into hold... mv -vf archive_spam/spam_mbox.* archive_spam/hold/ # Dump the 4 weeks of backups of spam mboxes... rm -vf archive_spam/spam_mbox.* # Set count back to 1... let count=1 fi diff mail/spam archive_spam/spam_template_mbox spam_empty=$? # Save this spam mbox unless it is empty... if [ ! $spam_empty ] then # Backup the current spam folder... cp mail/spam archive_spam/spam_mbox.$count # Copy over spam folder empty spam folder... cp -f archive_spam/spam_template_mbox mail/spam # Increment the backups counter... let count="$count + 1" else mail -s "The spam folder was empty at dump time!" ad...@robinson-west.com < archive_spam/count ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Help with email scripts...
On Sun, 23 Jun 2019, Michael Christopher Robinson wrote: I am having trouble using grep to grab subject lines from my spam folder on eskimo. Michael, Attachments are ripped off messages to this mail list. Regardless, have you considered using awk rather than grep? You can set /^Subject:/ as the pattern and the action will print the result to a specified file. Regards, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug