mailx creates unwanted attachment

Hi,

I run in a script a mailx command like this:

cat logfile | mailx -s’the logfile’ to-me@…

This works most of the time, but in some cases mailx automagically turns logfile into an attachment called ‘attachment.bin’

I think this may be because ‘logfile’ contains a few control characters or escape codes?

How can I tell mailx to be less intelligent and treat it as an ASCII text file?

I have:
mailx -V
12.2 01/07/07

TIA
Nico

How can I tell mailx to be less intelligent and treat it as an ASCII text file?

Once you’re intelligent it’s very hard to get rid of it …

You could try to upgrade mailx to 12.4 and see if this changes anything. Or pipe the logs through a filter converting characters outside the ASCII range to something else before feeding them into mailx.

On 2010-09-09 10:36, nvliet wrote:
>
> Hi,
>
> I run in a script a mailx command like this:
>
> cat logfile | mailx -s’the logfile’ to-me@…
>
> This works most of the time, but in some cases mailx automagically
> turns logfile into an attachment called ‘attachment.bin’
>
> I think this may be because ‘logfile’ contains a few control characters
> or escape codes?
>
> How can I tell mailx to be less intelligent and treat it as an ASCII
> text file?

You could try the -q option.

-q file
Start the message with the contents of the specified file.
May be given in send mode only.

Or read the manual…


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Minas Tirith))

I think this may be because ‘logfile’ contains a few control characters or escape codes?

mailx accepts this command line argument:

-S encoding=8bit

This could possibly solve your problem.

I realize this is an old post, but I ran across this situation and my problem was an extra return in the input file. I solved it by piping the file through tr. For example:

cat logfile | tr -d \\r | mailx -s'the logfile' to-me@.....

Old but usefull ! I got this problem and kroucher’s tr method worked for me. Thanks !