{"id":286,"date":"2011-02-25T12:55:43","date_gmt":"2011-02-25T04:55:43","guid":{"rendered":"https:\/\/patrick-nagel.net\/blog\/?p=286"},"modified":"2011-02-25T12:55:44","modified_gmt":"2011-02-25T04:55:44","slug":"emerge-output-ends-up-as-attachment-bin-when-sent-with-nail-heirloom-mailx","status":"publish","type":"post","link":"https:\/\/patrick-nagel.net\/blog\/archives\/286","title":{"rendered":"emerge output ends up as attachment.bin when sent with nail \/ Heirloom mailx"},"content":{"rendered":"<p>I really like the command line mailer <a href=\"http:\/\/heirloom.sourceforge.net\/mailx.html\">Heirloom mailx (formerly nail)<\/a>, and now there is even a current version in portage again (still under the name mail-client\/nail, but that doesn&#8217;t matter), so that&#8217;s even better. I use it on all servers, since it&#8217;s just convenient &#8211; it can handle attached files, UTF-8 etc. without any problems.<\/p>\n<p>But there was one problem that bothered me for months already: It involved my check_updates.sh script, which basically just calls <code>\/usr\/bin\/emerge -upvDN --nospinner world<\/code> for the host and all virtual servers, and then sends the output to me.<\/p>\n<p>The problem: emerge&#8217;s output always ended up as &#8216;attachment.bin&#8217;, attached to the (otherwise empty) mail, although I piped it into <code>mail -s \"Updates for $DATE\" root<\/code> where it should come out as the mail body. I knew that Heirloom mailx does that, as soon as it doesn&#8217;t &#8220;like&#8221; one of the characters in the input, but I couldn&#8217;t think of a reason why it would do that with emerge&#8217;s supposedly plain-ASCII output.<\/p>\n<p>Today I had enough of it, and fired up hexdump to investigate said &#8216;attachment.bin&#8217;, using the following command:<br \/>\n<code>hexdump -e '1\/1 \"%03d \\n\"' attachment.bin | sort -u<\/code><br \/>\nIt outputs the unique decimal values of any byte occurring in &#8216;attachment.bin&#8217; as a sorted list. I expected to find something above 127 &#8211; but the highest occurring value was 122 (&#8220;z&#8221;). I then checked the top part of the list, and to my surprise, found 008 (backspace) there. After removing those by piping the output through <code>tr -d '\\010'<\/code> (8<sub>dec<\/sub> = 10<sub>oct<\/sub>, and tr needs octal values), Heirloom mailx no longer put the text into &#8216;attachment.bin&#8217;. It now appears in the mail&#8217;s body, where it belongs.<\/p>\n<p>By the way, those backspaces (when interpreted) change<br \/>\n<tt>Calculating dependencies  ... done!<\/tt><br \/>\nto<br \/>\n<tt>Calculating dependencies... done!<\/tt><br \/>\n&#8230; so removing them is not a big loss. I&#8217;d like to know though, why they are there in the first place, even though the output doesn&#8217;t go to a TTY.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I really like the command line mailer Heirloom mailx (formerly nail), and now there is even a current version in portage again (still under the name mail-client\/nail, but that doesn&#8217;t matter), so that&#8217;s even better. I use it on all servers, since it&#8217;s just convenient &#8211; it can handle attached files, UTF-8 etc. without any &hellip; <a href=\"https:\/\/patrick-nagel.net\/blog\/archives\/286\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;emerge output ends up as attachment.bin when sent with nail \/ Heirloom mailx&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,2],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-gentoo-linux","category-linux-general","category-this-machine"],"_links":{"self":[{"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":8,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":294,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/posts\/286\/revisions\/294"}],"wp:attachment":[{"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/patrick-nagel.net\/blog\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}