Need help in an issue related to mailx

Hello,

I have a file temp.txt with the below contents :

Sep  9 03:04:51 adcsdp01 MAPDR2_00[60716]: Unable to open trace file adpstartarv.log. (Error 110 Resource temporarily unavailable) [ntservsserver.cpp 6754]
Sep  9 03:05:35 adcsdp01 MAPDR2_00[76986]: SAP Service ADPMR2_00 successfully started.
Sep  9 03:04:51 adcsdp01 MAPDR2_00[34879]: Unable to open trace file adpstartarv.log. (Error 19 Resource temporarily unavailable) [gtaserver.cpp 6754]

When I am trying to send the above file using mailx from Red Hat Server , I am getting file on my mailbox with incorrect layout i.e second line is starting in continuation with the very first line although the file has three separate lines

Below is the mailx command :

mailx -s "Sending mail" mailid < temp.txt

Below is the output which shows that second line didnt started in a new line :

Sep  9 03:04:51 adcsdp01 MAPDR2_00[60716]: Unable to open trace file adpstartarv.log. (Error 110 Resource temporarily unavailable) [ntservsserver.cpp 6754] Sep  9 03:05:35 adcsdp01 MAPDR2_00[76986]: SAP Service ADPMR2_00 successfully started.
Sep  9 03:04:51 adcsdp01 MAPDR2_00[34879]: Unable to open trace file adpstartarv.log. (Error 19 Resource temporarily unavailable) [gtaserver.cpp 6754]

Could someone Please help.

Thanks
Rahul

Hello Rahul,

Could you please check once in your file if there are any ^M characters present by command cat -v Input_file . If yes then you can remove them by tr -d '\r' < Input_file > output_file .

Thanks,
R. Singh

1 Like

Hello Ravinder,

Good Evening,

There is no

^M

character in the above file as seen from the

cat -v filename

command on the file.

Please post the output of cat -vet filename .

1 Like

try this

awk '1' ORS='\r\n' | mailx -s "Sending mail" mailed

code error in the above.

awk '1' ORS='\r\n' temp.txt | mailx -s "Sending mail" mailed
1 Like

Thanks. I will Check and reply.

Note that Microsoft Outlook/Exchange arbitrarily re-arranges (join and split) the lines in the mail body.
The only work-around that I know is to tar/zip the text and use an attachment.

1 Like

I also think that there is issue while sending the file using outlook. Since the issue was for a single line the team wrote a sed command to fix the issue and proceeded with the rest of the work.

Thanks for your help.