Timeline for Email issue with output of bash script blcheck
Current License: CC BY-SA 3.0
26 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 5, 2015 at 13:08 | comment | added | Snowie | @John1024 thanks again John, I've had a go at tidy up edit of post. | |
| Nov 4, 2015 at 22:33 | comment | added | John1024 | @Snowie Glad it's working. For future reference, it is considered good stackoverflow style for the OP (that's you, here) to respond to comments by editing his question (where full formatting is possible) to add the additional information. (Stackoverflow considers comments to be disposable and subject to deletion at any time.) | |
| Nov 4, 2015 at 8:59 | comment | added | Snowie |
@John1024 OK its working! - emailing to body. blcheck edited with mod to #colors as above & all /r rmoved. CMD that's working: ` ./blcheck-latest -v xx.xx.xx.xx | perl -pe 's/\e([^[]]|[.*?[a-zA-Z]|].*?\a)//g' | col -b | mail -s "blcheck latest date" email@address`
|
|
| Nov 4, 2015 at 8:14 | comment | added | Snowie | @John1024 comment box not enough to show u diff result. | |
| Nov 4, 2015 at 8:11 | comment | added | Snowie | OK done how do I best show u the diff outpu? | |
| Nov 4, 2015 at 7:18 | comment | added | John1024 |
@Snowie OK. Let's try dumping to file, say file1. Then run perl -pe 's/\e([^[]]|[.*?[a-zA-Z]|].*?\a)//g' file1 | col -b >file2. Then run diff file1 file2 and let's see where the differences really are.
|
|
| Nov 4, 2015 at 6:51 | comment | added | Snowie | @John1024 with all the \r & tput removed it still fails if I use -v verbose this char can be seen in email attachment when using -v. Sends to email body with no -v. Also sends if I dump to file then run perl -pe 's/\e([^[]]|[.*?[a-zA-Z]|].*?\a)//g' | col -b then mail | |
| Nov 4, 2015 at 6:31 | comment | added | John1024 |
@Snowie It looks to me like \r probably only appears in the output if verbose is set. It might be simpler to just try it without -v.
|
|
| Nov 4, 2015 at 6:08 | comment | added | John1024 |
@Snowie The ^M character appears in the script several times in the form \r. You can remove it by doing a search-and-replace in your favorite editor or by running sed 's/\\r/CR/g' blcheck >blcheck.new. However, ^M` is not one of the characters affected by your perl script and it seems like an unlikely character to trigger a problem with text attachment. Try removing it and see what happens but there is a chance that the problem is somewhere else.
|
|
| Nov 4, 2015 at 5:17 | comment | added | Snowie | @John1024 when I run script I use -v but either way the carriage returns ^M are there, when I output to file they can be seen & if send to email they r also there, not seen in output console of course. | |
| Nov 4, 2015 at 4:46 | comment | added | Snowie | @john1024 this is with the tput removed " PTR resolves to mydomain.com Matching against 3 blacklists 16%% dnsbl-3.uceprotect.net ^M 16%% dnsbl-3.uceprotect.net ✓ " This ^M character I guess is the problem | |
| Nov 4, 2015 at 3:58 | comment | added | John1024 |
@Snowie I downloaded blcheck as per your link. After I removed the calls to tput (as per this answer), I have tried running it and I do not find any escapes (\E) or alerts (\a) in the output. I tested this by running your perl script on the output, and then comparing with cmp: no difference. Can you tell under what circumstances the modified script produces these characters? Or, if not, can show me sample output that contains those characters so I can look in the source to try to see where they are coming from?
|
|
| Nov 4, 2015 at 2:57 | comment | added | Snowie | @John1024, cas, The reason its still mailing as attachment for me is the formatting, if I dump to file then remove Ctrl Char with: cat myfile | perl -pe 's/\e([^[]]|[.*?[a-zA-Z]|].*?\a)//g' | col -b > myfile-fixed I can then mail & as body. Now I know why but need to figure out how to edit blcheck so it outputs in an mailx email friendly way for me. | |
| Nov 4, 2015 at 1:28 | comment | added | Snowie | Thanks John1024 & cas - centos 6 with postfix as MTA - mailx.x86_64 12.4-8.el6_6 its from heirloom with a BSD licence. Also tried on server running same malix ver but with Exim & end up with an attachment. Another script I run pflogsumm.pl with the same mail cmd dumps it to email body OK. | |
| Nov 3, 2015 at 14:34 | comment | added | John1024 | @Snowie I am using bsd-mailx. The server is exim. | |
| Nov 3, 2015 at 9:36 | comment | added | Snowie | Thanks cas - centos 6 with postfix as MTA - mailx.x86_64 12.4-8.el6_6 | |
| Nov 3, 2015 at 8:32 | comment | added | cas |
@Snowie, just add #!/bin/bash as the first line and make it executable with chmod +x blcheck. then you can run it with just blcheck if it's in the PATH or ./blcheck if it's in current dir.
|
|
| Nov 3, 2015 at 8:31 | comment | added | cas |
are you using bsd-mailx or heirloom-mailx?
|
|
| Nov 3, 2015 at 7:55 | comment | added | Snowie | John1024 - wat MTA r u using? I just tried on server with exim MTA & also as attached file. | |
| Nov 3, 2015 at 7:22 | comment | added | Snowie | Hey John1024 - tried with bash & still arrives as an email attachment, which will drive me crazy as I just want to have a quick glance at email to make sure no blacklisting, the server is running Postfix MTA. | |
| Nov 3, 2015 at 7:06 | comment | added | John1024 |
@Snowie Glad it worked. (I cannot reproduce your email attachment issue: when I run the mail command that you provide, I get the output in the body of the email message.) Separately, blcheck is a bash script. So, for best results, you should call it as bash blcheck ...., not sh blcheck ... because, on many systems, sh is not bash.
|
|
| Nov 3, 2015 at 6:58 | comment | added | John1024 | @cas Good suggestion. I added the code for that. | |
| Nov 3, 2015 at 6:57 | history | edited | John1024 | CC BY-SA 3.0 |
added 520 characters in body
|
| Nov 3, 2015 at 6:52 | comment | added | cas |
You could also modify blcheck so that it uses colors if stdout is a terminal, and not use colors if stdout is a pipe. e.g. if [ -t 1 ] ; then RED=$(tput setaf 1) ; GREEN=... ; else RED= ; GREEN= ; ... ; fi
|
|
| Nov 3, 2015 at 6:47 | vote | accept | Snowie | ||
| Nov 3, 2015 at 6:54 | |||||
| Nov 3, 2015 at 6:15 | history | answered | John1024 | CC BY-SA 3.0 |