Formatting for mailx command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting for mailx command
# 1  
Old 12-20-2013
Wrench Formatting for mailx command

Hello all,

I am trying to send an email using mailx command.

I have a txt file which has formatting like:

Code:
root@machine# cat /export/home/test/summary.txt

                                                                 T A P O U T -  R A T I N G -  A U D I T -  S U M M A R Y - R E P O R T
                                                                                    =================================

TRANSDATE  OPERATOR CALLTYPE RECORDS_WITH_RATE_DIFF
---------- -------- -------- ----------------------
18-DEC-13  JPNJP    001                          34
17-DEC-13  JPNJP    001                          18

I am doing the following:

Code:
root@machine# LOG1=`cat /export/home/imranar/summary.txt`
root@machine# WT_MSG=`echo " $LOG1"`
root@machine# echo $WT_MSG|mailx -s " Subbject for mail" myemail@address.com

I am getting the body in the form :

Code:
T A P O U T - R A T I N G - A U D I T - S U M M A R Y - R E P O R T ================================= TRANSDATE OPERATOR CALLTYPE RECORDS_WITH_RATE_DIFF ---------- -------- -------- ---------------------- 18-DEC-13 JPNJP 001 34 17-DEC-13 JPNJP 001 18

I want the email body to show me the message in proper formatting as shown below:


Code:
                                                                 T A P O U T -  R A T I N G -  A U D I T -  S U M M A R Y - R E P O R T
                                                                                    =================================

TRANSDATE  OPERATOR CALLTYPE RECORDS_WITH_RATE_DIFF
---------- -------- -------- ----------------------
18-DEC-13  JPNJP    001                          34
17-DEC-13  JPNJP    001                          18

How can I do this ?

Regards
# 2  
Old 12-20-2013
You lose your original format with
Code:
WT_MSG=`echo " $LOG1"`

Mail the multi-line variable with
Code:
echo "$LOG1" | mail ...

# 3  
Old 12-20-2013
Why don't you use
Code:
mailx -s " Subbject for mail" myemail@address.com </export/home/imranar/summary.txt

?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail/mailx ignores newline formatting Problem.

I have a file hello.txt which i wish to send as a email body (not attachment). cat -ev hello.txt 1$ 2$ 3$ I use the following command to send the hello.txt as the email body. mailx -s "Alert" myteam@mycomp.com<hello.txt However, the email received has this in the email body 123... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. HP-UX

Help with Mailx command

I need to do below in mailx : 1. to list 2. CC list (I am using tilde command for this) 3. -r option 4. attach .csv file Below is the command i am using : ( echo '~c abc@xyz.com'; cat mailtext.txt; uuencode attach.csv attach.csv) | mailx -s "${SUBJECT}" -r "abc@xyz.com" -m ${MAIL_LIST}... (4 Replies)
Discussion started by: ManOfSteel
4 Replies

3. UNIX for Dummies Questions & Answers

Formatting not preserved when using mailx

I tried to send email through mailx, the text file is well formatted when i open in unix, but when received the mail in outlook, the column do not align with the heading. The text file contain the tablespace details which I spool out from database. Please advise. Do I need to specify any parameter... (4 Replies)
Discussion started by: fenocean
4 Replies

4. UNIX for Dummies Questions & Answers

mailx command

Hi, I am seeing that this command is sending mail even when the nawk command in untrue ( does not have any output ). I only want it to send mail, where it goes above the threshold, and has some output. nawk -F'(MOD dn="uid=)|(DEL dn="uid=)|' '/(MOD dn="uid=)|(DEL dn="uid=)/... (2 Replies)
Discussion started by: john_prince
2 Replies

5. Solaris

mailx command

Dear all, Every time if i use mailx it is asking for entering the From Address. I want to set it in some place, So that it will take it by default whenever we send mails. Pl help on this. Regards JeganR (2 Replies)
Discussion started by: jegaraman
2 Replies

6. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

7. UNIX for Dummies Questions & Answers

mailx and -s command

How does the -s command work with mailx. I know that -s is to create a symbolic link when being used with ln but i'm not sure what the command does with mailx. Anyone?:confused: (1 Reply)
Discussion started by: kjetterman
1 Replies

8. UNIX for Advanced & Expert Users

mailx command

hi, i want to pass a unix variable as the subject of the mail alongwith a string. My part of code is as below.. week_end_dt=`sqlplus -s rsamart@martdev.world/rsamart<<EOF SET FEED OFF; SET TIMING OFF; SET HEADING OFF; SET PAGESIZE 500; SET LINESIZE 1000; select... (14 Replies)
Discussion started by: Jalkukdi@10
14 Replies

9. Shell Programming and Scripting

mailx command help

Dear All, I need to send a mail to a group ( the address of which is in a .profile file)..My basic mailing functionality isn't working. When i try to run mailx -s "Hello" abc@xyz.com the command does not return to the prompt an runs infinitely. Request you to help me out here along with... (3 Replies)
Discussion started by: kaushikraman
3 Replies

10. Shell Programming and Scripting

mailx command

Hi friends, i have seen the following line in some unix shell script . can some one explain me what exactly the statement is meant for ? ========================================================= mailx -s " Master Data Transmission Report for $TODAY at $TIME " < /etc/tr/tmp/$tmplog... (5 Replies)
Discussion started by: sveera
5 Replies
Login or Register to Ask a Question