Results 1 to 6 of 6

Thread: mailx creates unwanted attachment

  1. #1

    Angry 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

  2. #2
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: mailx creates unwanted attachment

    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.
    Technology is 'stuff that doesn't work yet.' -- Bran Ferren

  3. #3
    Carlos E. R. NNTP User

    Default Re: mailx creates unwanted attachment

    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))

  4. #4
    Join Date
    Jan 2009
    Location
    Switzerland
    Posts
    1,529

    Default Re: mailx creates unwanted attachment

    I think this may be because 'logfile' contains a few control characters or escape codes?
    mailx accepts this command line argument:

    Code:
    -S encoding=8bit
    This could possibly solve your problem.
    Technology is 'stuff that doesn't work yet.' -- Bran Ferren

  5. #5

    Default Re: mailx creates unwanted attachment

    Quote Originally Posted by nvliet View Post
    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
    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:

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

  6. #6

    Default Re: mailx creates unwanted attachment

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •