LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-04-2017, 10:23 AM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
mailx [Binary content]


I'm running Slackware64 14.2 and using mail (mailx) as an email client from the command line. Occasionally, I get a message body of [Binary content], which generally means there is some non-ASCII character in the message somewhere. I can read the message find in a text editor with "offending" characters rendered with their correct accent-marks, etc.

Is there something I can set for mailx to go ahead and show these characters? Otherwise, it's a bit of a pain to have to save the message to a file and read it with an editor later.
 
Old 07-04-2017, 08:27 PM   #2
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
mfoley --

The dos2unix command may do what you need ( produce pure-d 7-bit ASCII for mailx ).

The dos2unix and unix2dos commands are available on SBo: misc/dos2unix

Check `man dos2unix` for options once it is installed from SBo.

HTH

-- kjh
 
Old 07-07-2017, 12:59 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
The problem isn't that I can read the message at all. If I save the message to disk, then use an editor to open it, I can see the message just fine, including special characters. But, I want to be able to see the message body from within mailx when I'm reading messages interactively.

One of the problem characters causing the [Binary content] response is the copyright character: ©. Which is hex A9.

I've tried setting 'print-all-chars' in my .mailrc file. I've tried 'set ttycharset=utf8'. Neither of these seem to work.

Maybe that copyright/A9 character is not utf-8. Perhaps a different charset?
 
Old 07-07-2017, 01:13 PM   #4
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Quote:
Originally Posted by mfoley View Post
The problem isn't that I can read the message at all. If I save the message to disk, then use an editor to open it, I can see the message just fine, including special characters. But, I want to be able to see the message body from within mailx when I'm reading messages interactively.

One of the problem characters causing the [Binary content] response is the copyright character: ©. Which is hex A9.

I've tried setting 'print-all-chars' in my .mailrc file. I've tried 'set ttycharset=utf8'. Neither of these seem to work.

Maybe that copyright/A9 character is not utf-8. Perhaps a different charset?
mfoley --

Oops.

Yes, I see ...

I thought you needed to 'sanitize' a text file for mailx send mode which I do like this when messing with pesky Windows files:

Code:
dos2unix -7 < text-file.txt |mailx -s "email subject" user@domain
Not sure about mailx read mode ... maybe mutt can handle your high-ASCII chars ?

Sorry.

-- kjh

p.s. Maybe if you export a different value for PAGER, it would work for you ?

man mailx # search for PAGER

Quote:
PAGER Pathname of the program to use in the more command or when crt variable is set.
The default paginator pg(1) or, in BSD compatibility mode, more(1) is used if
this option is not defined.
The less command displays high-ASCII as Hex-Codes for me using my ancient LESS variable:

Code:
export LESS="-iXG -e -m -Pm ?f%f .?lbLine %lb of %L:?pb%pb\%:?bbByte %bb:-..."

Last edited by kjhambrick; 07-07-2017 at 01:23 PM. Reason: add p.s.
 
Old 10-02-2017, 10:48 AM   #5
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
OK, I've figured out a solution from the sender side. Some of the messages have control characters; codeset isn't the issue. The messages have BEL characters, carriage-returns, ESCape, etc. Before piping one type of message (sbopkg update output) into mail I do:
Code:
/usr/sbin/sbopkg -q -c | tr "\n" "@@" | tr -d "[:cntrl:]" | tr "@@" "\n"
This sbopkg output has ESC sequences and CRs. I first translate the newlines to "@@" to preserve them, then deleted all control characters and translate the "@@" back to newlines.

Another one is:
Code:
tr -d "\r©\007"
This is to remove CRs, the copyright symbol (although that might actually be OK) and the BEL character. This is to cleanup the output of a todo script.

In the end, my problem was not the codeset but control characters that mailx chokes on.

kjhambrick, I tried setting PAGER to less, but it didn't work for me, even though when I use less on the actual text I'm going to email it does show the control characters as e.g. ^G, highlighted. Nevertheless, I still get the "[binary content]" message in mail. This fellow was able to get less working: https://unix.stackexchange.com/quest...-in-cron-mailx, but I was not. Perhaps I'm not specifying it correctly in .mailrc:
Code:
set PAGER /usr/bin/less
 
Old 04-26-2022, 06:35 AM   #6
stevenro
LQ Newbie
 
Registered: Nov 2004
Location: Billericay/Essex
Posts: 6

Rep: Reputation: 0
Wink How to find the ascii characters

I was also having issues with the output with mailx attaching a .BIN file when I wanted the output to be in the body of the email.
I have been using "tr -d \r" to fix this issue, which worked on basically all scripts I was running, until one day even with this in place I was still getting a .BIN file.
So I simply ran the script and piped this to 'cat -vet', so script|cat -vet and this showed me what characters were in the mix. The \r in the tr command sorts out any ^M characters, but this time is was getting some ^G characters, which looking up the ascii character set (https://docstore.mik.ua/orelly/unix3...ut/appa_01.htm) the octal for this is 007. So to fix the output to my script to work with mailx I simply use: script | tr -d "\007\r" |mailx -s "Test" somebody@nowhere.com

So 'cat -vet' is your friend to assist you with what characters are in place for you to apply the necessary octal value to delete.
 
  


Reply

Tags
binary, content, mailx



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux utility to combine two or more binary files into a single binary file mageshvan Programming 7 05-05-2011 08:06 AM
Dividing content of one file by content of another larspend Linux - Newbie 5 04-12-2011 08:00 PM
XOR Binary Stream Against a Known Binary Key telecom_is_me Programming 14 07-04-2008 07:10 PM
Do I need binary 1 and binary 2 dvd iso for base install? salah-ad-din Debian 5 08-15-2006 04:43 PM
Apache serving content after the content is removed? jrbush82 Linux - Software 6 05-05-2004 04:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration