How to escape the tabspaces while sending email?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to escape the tabspaces while sending email?
# 1  
Old 07-23-2013
How to escape the tabspaces while sending email?

Hello All,

I have below excerpt from a shell script(bash) and the output from it as shown below. How do i make the email come out with message body left justified. As of now because of those tabs the message is coming out with those tab spaces. May i please know how can i supress them?

Code:
                if [ $( echo "${TOT_PRINCIPAL_BALANCE_DOLLARS} == ${COMP_PRINCIPAL_BALANCE_DOLLARS}" | bc -l ) -eq 1 ]
                then
                        logit "Principal Balance Dollars For Uninum($UNINUM): ${TOT_PRINCIPAL_BALANCE_DOLLARS} Matches With ${COMP_PRINCIPAL_BALANCE_DOLLARS}"
                else
                        logit "Principal Balance Dollars For Uninum($UNINUM): ${TOT_PRINCIPAL_BALANCE_DOLLARS} Doesn't Match With ${COMP_PRINCIPAL_BALANCE_DOLLARS}"
                        ((i+=1))
                        #ARR[$i]="Principal Balance Dollars For Uninum($UNINUM): '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'"
                        ARR[$i]="
                                Uninum: $UNINUM
                                Provider: $PROVIDER
                                Principal Balance Dollars: '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'
                                "
                fi


  if [ ${#ARR[*]} -gt 0 ]
        then
                logit "Array is not empty, Email Will Be Sent Out As The Hash Total Comparisions Is NOT Successful"
                #printf "%s\r\n" "${ARR[@]}" | /usr/bin/mutt -s "ALERT: Stage Hash Total Comparision Inconsistencies" "${EMAIL_LIST}" -i "${6}"
                printf "%s\r\n" "${ARR[@]}" | /usr/bin/mutt -s "$HOST - $DBSRC - ALERT: Stage Hash Total Comparision Inconsistencies" "${EMAIL_LIST}"
        else
                logit "Array is empty, Email Will Not Be Sent Out As The Hash Total Comparisions Is Successful"
        fi

Email Body Output:

Code:
				Uninum: 710056
				Provider: 16
				Principal Balance Dollars: '183498286.85' Doesn't Match With '183498285'


Last edited by Ariean; 07-23-2013 at 02:25 PM..
# 2  
Old 07-23-2013
Quote:
Originally Posted by Ariean
Hello All,

I have below excerpt from a shell script(bash) and the output from it as shown below. How do i make the email come out with message body left justified. As of now because of those tabs the message is coming out with those tab spaces. May i please know how can i supress them?

Code:
                if [ $( echo "${TOT_PRINCIPAL_BALANCE_DOLLARS} == ${COMP_PRINCIPAL_BALANCE_DOLLARS}" | bc -l ) -eq 1 ]
                then
                        logit "Principal Balance Dollars For Uninum($UNINUM): ${TOT_PRINCIPAL_BALANCE_DOLLARS} Matches With ${COMP_PRINCIPAL_BALANCE_DOLLARS}"
                else
                        logit "Principal Balance Dollars For Uninum($UNINUM): ${TOT_PRINCIPAL_BALANCE_DOLLARS} Doesn't Match With ${COMP_PRINCIPAL_BALANCE_DOLLARS}"
                        ((i+=1))
                        #ARR[$i]="Principal Balance Dollars For Uninum($UNINUM): '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'"
                        ARR[$i]="
                                Uninum: $UNINUM
                                Provider: $PROVIDER
                                Principal Balance Dollars: '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'
                                "
                fi

Email Body Output:

Code:
				Uninum: 710056
				Provider: 16
				Principal Balance Dollars: '183498286.85' Doesn't Match With '183498285'

Change:
Code:
                        ARR[$i]="
                                Uninum: $UNINUM
                                Provider: $PROVIDER
                                Principal Balance Dollars: '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'
                                "

to:
Code:
                        ARR[$i]="
Uninum: $UNINUM
Provider: $PROVIDER
Principal Balance Dollars: '${TOT_PRINCIPAL_BALANCE_DOLLARS}' Doesn't Match With '${COMP_PRINCIPAL_BALANCE_DOLLARS}'
"

# 3  
Old 07-23-2013
I thought i could use something similar to this "<<-EOF ....... EOF" but it's not working. Just want to make code more readable and pretty
# 4  
Old 07-23-2013
There are lots of ways to set a variable to a string value. When you put tabs in the string and you later print the saved value, the tabs will be there. The suggestion I made before is fast, efficient, and pretty obvious; but not pretty. If you want pretty, but less efficient, one possibility (out of thousands of possibilities) is:
Code:
                        ARR[$i]="$(printf "\n%s\n%s\n%s %s %s %s\n" \
                                 "Uninum: $UNINUM" \
                                 "Provider: $PROVIDER" \
                                 "Principal Balance Dollars:" \
                                 "'${TOT_PRINCIPAL_BALANCE_DOLLARS}'" \
                                 "Doesn't Match With" \
                                 "'${COMP_PRINCIPAL_BALANCE_DOLLARS}'")"

This User Gave Thanks to Don Cragun For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Sending an email using mutt...

I wanted to send "config.log" to the usergroup that handles open source support for Octave 3.8.0, a programming language as there were build errors. In order to send an email from unix command line, I am trying to use mutt, and I need a straightforward way of sending emails, as the commands... (1 Reply)
Discussion started by: jon80
1 Replies

2. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

3. Shell Programming and Scripting

sending an email with attachment

Hi, Please help me in sending an e-mail with attachment through unix mailx command is not present in our unix box. (4 Replies)
Discussion started by: dudd9
4 Replies

4. Linux

sending an email

I have used an already-built ActiveX control to send email from my asp web pages. One of the parameters I fill is FromName which defines the tittle the recipient will see in the From entrance in his Inbox. Now Iīm trying to use mail to send an email from a Shell but I havenīt found the... (1 Reply)
Discussion started by: RandomAccess
1 Replies

5. Shell Programming and Scripting

Sending Email with Attachment

Hi, I want to send an email with multiple attachment using uuencode and mail command. I am able to send with one attachment Ex:uuencode abc.txt abc.txt | mail test@test.com -s "Test3" Can anyone reply with syntax. Regards BS (3 Replies)
Discussion started by: balajiora
3 Replies

6. UNIX for Dummies Questions & Answers

help sending the date in an email

Hi all, I'm new to the forums. Let me start off by saying UNIX is great to use and I enjoy using it. That being said I am just learning how to use it in college and I need help with an assignment. The assignment is I have to use crontab to find out when my teacher logs in on the upcoming weekend... (2 Replies)
Discussion started by: roflmywaffle
2 Replies

7. Shell Programming and Scripting

I have some problem in sending an email, please help me.

Hi, I am writing a kornshell script, once the successful completion of the script I need to send an email with body of a text along with an attachment. But i couldnt able to send an email with both body of the text and attachment at the same time in unix. The following is the code i tried, ... (2 Replies)
Discussion started by: Sheethal
2 Replies

8. UNIX for Dummies Questions & Answers

sending email

hi, is there any possiblity to send email from the command prompt, for eg i want to send alert to any mail id like /data/logs is 80% to my hotmail account , xxx@hotmail.com is this really possible,, if not, then what are the prerequistes need to do this (1 Reply)
Discussion started by: vasikaran
1 Replies

9. Shell Programming and Scripting

sending email in unix. need help!

how can I send an email in UNIX, attach a file and cc a receipient? i use the command below to attach a file (this works): uuencode path/filename filename | mailx -s "subject" addr@host.com here is how i cc a receipient (this also works): i have a file named cc.lis and contains: Hello... (2 Replies)
Discussion started by: tads98
2 Replies

10. UNIX for Dummies Questions & Answers

Sending email

I have an Solaris 8 machine running a managment application. One of the features of this application is to configure alarm forwarding to an email undress. When i configured the application to do that, it asked me only about the recipient email address. Quesiton: how to configure my Solaris 8... (7 Replies)
Discussion started by: bcheaib
7 Replies
Login or Register to Ask a Question