Linux mail format problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux mail format problem
# 1  
Old 10-28-2011
Linux mail format problem

I am trying to use Linux mail command on red hat linux. It is working fine except when there is hardcoded "\n" characters in the file content i want to send. It is literally taking "\n" as text and message is not getting formatted to give newliine effect.

I am using the following command:

cat ${file-name} | mail -s "Sub" "a.b@c.com"

if the file is regular file with newlines, the output is fine.

But when "\n" is in the text... For Eg:

file contents are like:
ab\ncdefgh\n
add\nadda\n

then it is taking all those \n as characters and printing in the mail as it is. I was expecting it to format as newline as mailx does on solaris.

Please let me know my options.

I already tried:

echo -e
printf
# 2  
Old 10-28-2011
If \n is embedded in a normal text file, then it will treat \n as normal character.
Try this...
Code:
awk '{print "echo -e \""$0"\""}' inputfile | bash | mail -s ...

--ahamed

---------- Post updated at 09:16 PM ---------- Previous update was at 09:08 PM ----------

or

Code:
xargs -0 -I arg echo -e arg  < input_file | mail -s...

--ahamed

Last edited by ahamed101; 10-28-2011 at 01:28 AM..
# 3  
Old 10-28-2011
Code:
$ echo -e "$(<file-name)"|mailx -s "Sub" "a.b@c.com"

# 4  
Old 11-01-2011
Quote:
Code:
xargs -0 -I arg echo -e arg  < input_file | mail -s...

--ahamed
Thanks a lot
This seems to be working for most of the scenario except html.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To have a mail in tabular format

Hello Guys, developing a monitoring shell script to have my queue depth count over mail . here is the sample input file to the script which has all the queue names 1 : DISPLAY QUEUE(*) WHERE (CURDEPTH GT 0) ZFC8409: Display Queue details. QUEUE(QL.GVR.ATA.CACHE.01) ... (10 Replies)
Discussion started by: wims
10 Replies

2. Shell Programming and Scripting

Mail Format Issues

Hi All, I 'm trying to find a way to send my contents of a file as a body of email in the format shown below. However, the format of the contents are messed up when I receive the email. ---------------------------------------------------------------------------------------------------------... (2 Replies)
Discussion started by: shash
2 Replies

3. Red Hat

Problem with mail utility on linux

Hi, I am facing problem with "mail" utility on redhat linux. If I use ~c in a file and use that file as imput to mail, the mail is not sent to the adrress after ~c. Instead ~c apears in the mail content itself. $ mail a@mycompany.com < temp $ cat temp ~c abc@mycompany.com this is... (7 Replies)
Discussion started by: shriashishpatil
7 Replies

4. Shell Programming and Scripting

[Solved] Problem with mail commands & format

1. I generated a log for the script. log: abc def ghi ijk If I use general (plain text) format for mail sending, it was displaying correctly with new lines where I have. Eg: abc def ghi ijk But I tried with HTML format using the code: (8 Replies)
Discussion started by: karumudi7
8 Replies

5. Ubuntu

problem in linux ubuntu 10.10 about mail command

Hi, My question is that is there any substitute command for mail in ubuntu because I'm trying to run it and it is showing error: command not found!! Will it need to download any specific package? If so please tell me how can I download that pkg. Thanks in advance. (1 Reply)
Discussion started by: nageshgautam
1 Replies

6. Linux

problem to format linux partition

hi friends one week ago, i have installed fedoa 9 on my home pc. i already have windows xp on that machine. unfortunately my windows xp has corrupted. again i want to install windows xp but it is not installing. will i format my linux partition or some other option is there. please help me... (0 Replies)
Discussion started by: praneshmishra08
0 Replies

7. Red Hat

redhat linux mail server problem

we are using redhat linux,configured the postfix as mail server and outlook is used as mail client.whenever the user opens outlook it is start downloading all the mails from the server. Example : If a user has 50 mails in the server,whenever he opens the outlook the outlook will start... (0 Replies)
Discussion started by: ramjimh2k3
0 Replies

8. Shell Programming and Scripting

mail format problem:

i need to send 2 diff mail in a single script:Below the script #!/bin/ksh echo "enter the number" read num if then mail -s "test" unix@yahoo.com mail -s "test" 9886767000@nma.vodafone.in,9916138003@nma.vodafone.in else echo "test again" fi... (5 Replies)
Discussion started by: ali560045
5 Replies

9. Shell Programming and Scripting

mail format problems

Hi, I have a script that runs off the cron and creates a report, carries out a few checks and then sends the info in a email (i'm using mailx). To exectute the sending from the script all I do is, cat $reportfile | mailx -s "The Subject" my.email@work.com When I test running this... (4 Replies)
Discussion started by: nhatch
4 Replies

10. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies
Login or Register to Ask a Question