在RedHat Linux中使用.dat附件而不是使用mailx的文本 [英] .dat attachment instead of text using mailx in RedHat Linux
问题描述
我正在尝试将文本文件的内容作为附件的正文发送.在HP-UX上可以正常工作,但是我们最近已迁移到RedHat Linux,并且不再按预期工作.
I am trying to send the contents of a text file as the body of an attachment. This works fine in HP-UX, but we've recently moved to RedHat Linux, and it is no longer working as expected.
这是我的命令
cat test.txt | mailx -stest me@email.ca
如果"test.txt"包含低位ASCII字符,则可以正常工作.但是,我的文本文件可能包含法语字符,并且将始终包含注册商标符号.看来,当我尝试发送这些字符时,Linux会将电子邮件转换为附件(格式为attxxxxx.dat).该附件包含我所有的数据,格式完美,但是我的收件人只希望发送一封普通电子邮件-而不是"dat"附件.我们尝试设置环境变量,并将扩展字符集命令放入mailx命令,但无济于事.
If "test.txt" contains low ASCII characters, then it works fine. However, my text file may have French characters and will always contain a registered trademark symbol. It seems that when I try to send those characters, Linux is converting the email into an attachment (in the form attxxxxx.dat). The attachment has all my data, perfectly formed, but my recipients just want a plain email - not a "dat" attachment. We've tried setting the environment variables and putting extended character set commands in the mailx command, to no avail.
任何建议或想法将不胜感激.
Any suggestions or ideas would be greatly appreciated.
推荐答案
请确保您的文件编码与系统上设置的语言环境(人工语言环境)相同.您可以将文件转换为相应的语言环境(例如,使用iconv
),也可以将系统的语言环境设置为当前文件的编码.此外,请确保从文件中删除所有回车符
Make sure that your file encoding is the same as the locale (man locale) set on your system. Either convert your file (e.g. using iconv
) to the according locale or set the locale of the system to the current file encoding. Moreover make sure to remove any carriage returns from the file
cat test_1.txt | tr -d '\r' > test_2.txt;
然后cat test_2.txt | mailx -s 'Test' me@email.ca;
应该可以正常工作.
Then cat test_2.txt | mailx -s 'Test' me@email.ca;
should work correctly.
这篇关于在RedHat Linux中使用.dat附件而不是使用mailx的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!