SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to send some file which generated by script to my email. when I run the script I'm getting an email. Thats fine. But it seems to be all messed up like below
Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st DEV POrt are OK on ServerA. Service is running. Memory Status on ServerB: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st DEV POrt are OK on ServerB. Service is running.on ServerB
I want to make it seperate lines like below
Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerA.
Service is running on ServerA.
Memory Status on ServerB: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerB: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerB.
Service is running on ServerB.
$ mail -s "Health Check Status" uname@company.com << EOF
> $(cat /home/uname/Result)
> EOF
$
$ mail -s "Health Check Status" uname@company.com < <(cat /home/uname/Result)
$
I tried this but still the same thing. email message looks very messy.
That ought to work. What do the contents of /home/uname/Result look like? If they don't look OK then how are you creating the file?
my intial post was actuvally /home/uname/Result file. Im generating this file as script output.
in the file it looks good. But in email message only messy.
[snip]
in the file it looks good. But in email message only messy.
Can we just attach the file instead. Thanks
AFAIK the mail command does not support attachments.
Have replicated your method and it worked as you want:
Code:
c@CW8:~$ cat Result
Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerA.
Service is running on ServerA.
Memory Status on ServerB: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerB: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerB.
Service is running on ServerB.
c@CW8:~$ mail -s "Health Check Status" root < Result
c@CW8:~$ dpkg -l mailx | grep mailx
ii mailx 1:8.1.2-0.20071017cvs-2 A simple mail user agent
Mail was received (in MS Outlook) looking just fine.
Time to dig into the details. Mail/mailx/mail has been around for a long time and is (?) no longer being developed. It is unlikely that the different behaviour on your system and mine is caused by features of different versions.
Stupid question first. How are you viewing the mail when you see it with line ends and empty lines replaced with spaces?
Do you have a ~/.mailrc file. If so, rename it to something else and try again, to see if it's something in there that's causing the problem.
What does your /etc/mail.rc file look like. Here's mine, not touched since installation
Code:
c@CW8:~$ cat /etc/mail.rc
set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To
The line termination characters are different in unix and windows, and that sometimes causes a problem. I think a lot of newer win apps are able to handle the nix EOL, but there are still some out there (eg. notepad) that won't handle it. if you're using an older version of outlook it might still have the problem.
if attaching the doc works for you, you could always uuencode it and pass it to the mail prog, like so:
Code:
uuencode /home/uname/Result Result.txt | mail -s "Health Check Status" uname@company.com
for some reason my distro doesn't have uuencode, but i found a gmime pkg that does the same; instead of uuencode use gmime-uuencode.
The line termination characters are different in unix and windows, and that sometimes causes a problem. I think a lot of newer win apps are able to handle the nix EOL, but there are still some out there (eg. notepad) that won't handle it. if you're using an older version of outlook it might still have the problem.
if attaching the doc works for you, you could always uuencode it and pass it to the mail prog, like so:
Code:
uuencode /home/uname/Result Result.txt | mail -s "Health Check Status" uname@company.com
for some reason my distro doesn't have uuencode, but i found a gmime pkg that does the same; instead of uuencode use gmime-uuencode.
Interesting suggestions. FWIW, I routinely send reports generated by smartmontools on ubuntu to myself using "mail" and they look OK in Outlook 2003.
I've never used uuencode. Will that be readable by most email readers?
Can you send a copy to yourself on the Linux system and see what it looks like there? It would help to know when the mangling happens -- on the Linux system or later. The mail -c option followed by your username (without any @domain_name) should do it.
What are you using to send the mail from your Linux system to wherever? postfix, sendmail ... ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.