send an email of script output

Hi All,

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.

Is there anyway to do so in the script. Thanks.

What is the code that is generating the inappropriate output?

Hi.

This is most likely happening because windows expects a CRLF (carriage-return linefeed) (^M^J) character and UNIX has only the LF (^J) character.

You can easily convert the file using

unix2dos

before you send it.

Or you could send it via attachment using

uuencode myfile myfile.txt | mail......

and use something other than Notepad to open it.

(I did make one assumption: you are trying to read the file in Windows!)

How is the script generating the output? If it is using echo, then you should use "echo -e" with \r at the end.

If you use it then you should not have CR problems when outputting data to an email (or to a text file).

(I am also assuming you are trying to email it and read on a Windows machine That's what I was doing when I found this answer... )

Please post the script which generates the mail and state which Operating System you use and which shell. Also please state your Mail Reader and version.

Sometimes this problem is caused by an unwanted setting in Microsoft Office Outlook which should be unchecked:

Tools/Options/Preferences/E-mail options/Remove extra line breaks in plain text messages