Visit Our UNIX and Linux User Community


Formatting The Email Output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Formatting The Email Output
# 1  
Old 07-31-2013
Formatting The Email Output

Hello All,
When i use the single quotes around the variables i am getting each line in the array as seperate in the email as shown in code2 & output2. But i don't want those single quotes to be printed but each array element should be printed as seperate line as when i remove those single quotes the elements are getting merged and printed as single line.

Code1:
Code:
ARR[$i]="Loan Row Count : $TOT_LOAN_ROW_COUNT Doesn't Match With $COMP_LOAN_ROW_COUNT"

Output1:
Code:
Loan Row Count : 1312 Doesn't Match With 1311 Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Code2:
Code:
ARR[$i]="Loan Row Count : '$TOT_LOAN_ROW_COUNT' Doesn't Match With '$COMP_LOAN_ROW_COUNT'"

Output2:
Code:
Loan Row Count : '1312' Doesn't Match With '1311'
Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Email Code:
Code:
printf "%s\r\n" "
Extract Date: $4
Provider: $1
Uninum: $3
Version Number: $2

${ARR[@]}" | /usr/bin/mutt -s "ALERT: $HOST - $DBSRC - Stage Hash Totals Comparision Inconsistencies" "${EMAIL_LIST}"

Excepted Output:
Code:
Loan Row Count : 1312 Doesn't Match With 1311
Book Value Dollars : 519090514.68 Doesn't Match With 519090515

---------- Post updated at 01:07 PM ---------- Previous update was at 12:38 PM ----------

I did this but still i am seeing an empty line because of "\n" what to get rid of it.

Code:
 printf "%s\r\n" "
Extract Date: $4
Provider: $1
Uninum: $3
Version Number: $2

`for i in "${ARR[@]}"
do
echo -e $i"\n"
done`
" | /usr/bin/mutt -s "ALERT: $HOST - $DBSRC - Stage Hash Totals Comparision Inconsistencies" "${EMAIL_LIST}"

Output:
Code:
Extract Date: 2012-09-30
Provider: 16
Uninum: 710119
Version Number: 1

Loan Row Count : 1312 Doesn't Match With 1311

Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Principal Balance Dollars : '513703522.97' Doesn't Match With '513703520', Difference is: '2.97'

PD Rating Values : '8903' Doesn't Match With '8900', Difference is: '3'

---------- Post updated at 01:37 PM ---------- Previous update was at 01:07 PM ----------

Quote:
Originally Posted by Ariean
Hello All,
When i use the single quotes around the variables i am getting each line in the array as seperate in the email as shown in code2 & output2. But i don't want those single quotes to be printed but each array element should be printed as seperate line as when i remove those single quotes the elements are getting merged and printed as single line.

Code1:
Code:
ARR[$i]="Loan Row Count : $TOT_LOAN_ROW_COUNT Doesn't Match With $COMP_LOAN_ROW_COUNT"

Output1:
Code:
Loan Row Count : 1312 Doesn't Match With 1311 Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Code2:
Code:
ARR[$i]="Loan Row Count : '$TOT_LOAN_ROW_COUNT' Doesn't Match With '$COMP_LOAN_ROW_COUNT'"

Output2:
Code:
Loan Row Count : '1312' Doesn't Match With '1311'
Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Email Code:
Code:
printf "%s\r\n" "
Extract Date: $4
Provider: $1
Uninum: $3
Version Number: $2

${ARR[@]}" | /usr/bin/mutt -s "ALERT: $HOST - $DBSRC - Stage Hash Totals Comparision Inconsistencies" "${EMAIL_LIST}"

Excepted Output:
Code:
Loan Row Count : 1312 Doesn't Match With 1311
Book Value Dollars : 519090514.68 Doesn't Match With 519090515

---------- Post updated at 01:07 PM ---------- Previous update was at 12:38 PM ----------

I did this but still i am seeing an empty line because of "\n" what to get rid of it.

Code:
 printf "%s\r\n" "
Extract Date: $4
Provider: $1
Uninum: $3
Version Number: $2

`for i in "${ARR[@]}"
do
echo -e $i"\n"
done`
" | /usr/bin/mutt -s "ALERT: $HOST - $DBSRC - Stage Hash Totals Comparision Inconsistencies" "${EMAIL_LIST}"

Output:
Code:
Extract Date: 2012-09-30
Provider: 16
Uninum: 710119
Version Number: 1

Loan Row Count : 1312 Doesn't Match With 1311

Book Value Dollars : 519090514.68 Doesn't Match With 519090515

Principal Balance Dollars : '513703522.97' Doesn't Match With '513703520', Difference is: '2.97'

PD Rating Values : '8903' Doesn't Match With '8900', Difference is: '3'


When i printed the output of the array to standard output it is printing fine as below, how do i get the same output in email as well please help.

Code:
Loan Row Count : 1312 Doesn't Match With 1311
Book Value Dollars : '519090514.68' Doesn't Match With '519090515'
Principal Balance Dollars : '513703522.97' Doesn't Match With '513703520', Difference is: '2.97'
PD Rating Values : '8903' Doesn't Match With '8900', Difference is: '3'

# 2  
Old 07-31-2013
In Unix land please do not use the unprintable special character \r
Code:
printf "%s\n" "
text
text"

or
Code:
echo "
text
text"

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #657
Difficulty: Easy
The last retail version of MS-DOS was MS-DOS 7.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

2. UNIX for Dummies Questions & Answers

Email formatting gets disturbed because of screen resolution

Hi friends, I have written a shell script which send a report to email address everyday. The report is generated on UNIX server every day, Generated report is sent to 25 users through cron. All 25 users have set different screen resolution for their monitor. The email looks wel formatted for... (4 Replies)
Discussion started by: Nakul_sh
4 Replies

3. Shell Programming and Scripting

Formatting output

I have the output like below: DEV#: 9 DEVICE NAME: hdisk9 TYPE: 1750500 ALGORITHM: Load Balance SERIAL: 68173531021 ========================================================================== Path# Adapter/Path Name State Mode Select Errors 0 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

4. Shell Programming and Scripting

[Solved] Sending a HTML email from cli loses formatting.

Hi, I have a .sh file, to email a report of our backups from a linux machine. It looks like this (minus a few bits): echo "HELO $host.$domain" sleep 1 echo "mail from: vdrreport@$domain" sleep 1 echo "rcpt to:$mailto" sleep 1 echo "data" sleep 1 echo "subject: $host VDR-Report... (2 Replies)
Discussion started by: cognito
2 Replies

5. Windows & DOS: Issues & Discussions

email from *nix to Exchange - text formatting issue

Oracle Linux 5.6 x-86-64 (Red Hat derivitive) I have several shell scripts that capture output to a log file, then use that log file as the source of an email. For a very simplified example: echo Today is `date` >> $logfile /bin/mail -s "$subject" "$sendto" < $logfile (yes, $subject... (6 Replies)
Discussion started by: edstevens
6 Replies

6. Shell Programming and Scripting

Need help with output formatting

Hey can anyone help me with newline formatting? i bet someone will ask why im rewriting du code, im trying to write a simple script that have slightly different function than du lol.... echo $(du "$dval" | tr ' ' '\n') atm with above code it will printout i've tried sed and awk... cant... (7 Replies)
Discussion started by: Nick1097
7 Replies

7. UNIX for Dummies Questions & Answers

Formatting df output

Hi all, Can anyone please suggest how best to handle output from running df where some of the information for a volume/filesystem spread over two lines? Some of my volume/filesytem are NFS mounted and when I run a df, the information is spread over the two lines instead of the usual norm... (4 Replies)
Discussion started by: newbie_01
4 Replies

8. Shell Programming and Scripting

Output formatting .

below is a CPU utilization Log for ABC server. However for every 15 minutes it generates 3 CPU values(with interval of 2 sec). Host CPU CPUtotal CPU% time ABC 101.1 2 50.55 14 : 15 ABC 100.5 2 50.25 14 : 15 ABC 100.2 2 50.1 14 : 15 ABC 100.9 2 50.45 14 : 30 ABC 100.5 2 50.25 14 : 30 ABC... (5 Replies)
Discussion started by: pinga123
5 Replies

9. Shell Programming and Scripting

more help with formatting ls output...

Ok, for a fun project, my goal is to replicate the style of "catalog" on an old apple ] *A 002 SOMEAPPLESOFTFILE B 004 SOMEFILE T 006 SOMETEXT I 002 SOMEINTEGERFILE The first character is either " " or "*" depending on if the file is locked or not. Next is the filetype, so in... (1 Reply)
Discussion started by: patrick99e99
1 Replies

10. Shell Programming and Scripting

Email formatting

ok, does anyone know how i can strip out fields i dont want from a mail spool file (eg: /var/mail/usermailbox) and dump to standard output (or file with > filename) ?? i tried using a bunch of grep -v 's but i realized that has two main problems, first of all, if anyone types the text im grepping... (6 Replies)
Discussion started by: norsk hedensk
6 Replies

Featured Tech Videos