E-mail Output Merge Lines for Some Text..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting E-mail Output Merge Lines for Some Text..
# 1  
Old 06-19-2014
E-mail Output Merge Lines for Some Text..

Hi all.

This is the content of the text file used for the e-mail:
Code:
TM ICP-EDW BILLING REGISTER USAGE BREAKDOWN_01062014.csv
TM_ICP_EDWH_FICL_13062014.TXT
TM_ICP_EDWH_FICL_16062014.TXT
TM_ICP_EDW_Detailed Payment Journal Report_13062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_14062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_15062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_16062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_17062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_18062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_19062014.txt
TM_ICP_EDW_FA_REFUND_CONSUMER_01062014.csv
TM_ICP_EDW_FA_REFUND_SME_01062014.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140613.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140614.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140615.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140616.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140618.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140619.csv
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_12062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_14062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_16062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_17062014.txt
TM_ICP_EDW_LIST_OF_ACCOUNT_WITH_STREAM_CODE_2_3_SERIES_01062014.csv
TM_ICP_EDW_PELANGGAN_ATD_DAN_ANTARABANGSA(OPR)_N_01062014.csv

This is the command that is used:
Code:
{ echo "FIRST" ; cat ftp_list.txt ; echo "LAST" ; } | /usr/bin/mailx -s "CAMELOT-MS Portal Missing Reports" my_email@company.com

But when the e-mail is received, this is what I actually get:
Code:
FIRST
TM ICP-EDW BILLING REGISTER USAGE BREAKDOWN_01062014.csv TM_ICP_EDWH_FICL_13062014.TXT TM_ICP_EDWH_FICL_16062014.TXT TM_ICP_EDW_Detailed Payment Journal Report_13062014.txt TM_ICP_EDW_Detailed Payment Journal Report_14062014.txt TM_ICP_EDW_Detailed Payment Journal Report_15062014.txt TM_ICP_EDW_Detailed Payment Journal Report_16062014.txt TM_ICP_EDW_Detailed Payment Journal Report_17062014.txt TM_ICP_EDW_Detailed Payment Journal Report_18062014.txt TM_ICP_EDW_Detailed Payment Journal Report_19062014.txt TM_ICP_EDW_FA_REFUND_CONSUMER_01062014.csv
TM_ICP_EDW_FA_REFUND_SME_01062014.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140613.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140614.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140615.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140616.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140618.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140619.csv
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_12062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_14062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_16062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_17062014.txt
TM_ICP_EDW_LIST_OF_ACCOUNT_WITH_STREAM_CODE_2_3_SERIES_01062014.csv
TM_ICP_EDW_PELANGGAN_ATD_DAN_ANTARABANGSA(OPR)_N_01062014.csv
LAST

It sort of it has something to do with those filenames with spaces in it.

Could this be fixed?

Thanks a lot.

---------- Post updated 06-20-14 at 12:48 AM ---------- Previous update was 06-19-14 at 01:59 PM ----------

The problem is weird right? Anyone?

TQ.
# 2  
Old 06-19-2014
Check your input file for any control characters using od or cat
Code:
od -c ftp_list.txt

OR
Code:
cat -evt ftp_list.txt

This User Gave Thanks to Yoda For This Post:
# 3  
Old 06-19-2014
This is the output

$ od -c ftp_list.txt
Code:
0000000   T   M   _   I   C   P   _   E   D   W   H   _   F   I   C   L
0000020   _   1   3   0   6   2   0   1   4   .   T   X   T  \n   T   M
0000040   _   I   C   P   _   E   D   W   H   _   F   I   C   L   _   1
0000060   6   0   6   2   0   1   4   .   T   X   T  \n   T   M   _   I
0000100   C   P   _   E   D   W   _   D   e   t   a   i   l   e   d
0000120   P   a   y   m   e   n   t       J   o   u   r   n   a   l
0000140   R   e   p   o   r   t   _   1   4   0   6   2   0   1   4   .
0000160   t   x   t  \n   T   M   _   I   C   P   _   E   D   W   _   D
0000200   e   t   a   i   l   e   d       P   a   y   m   e   n   t
0000220   J   o   u   r   n   a   l       R   e   p   o   r   t   _   1
0000240   5   0   6   2   0   1   4   .   t   x   t  \n   T   M   _   I
0000260   C   P   _   E   D   W   _   D   e   t   a   i   l   e   d
0000300   P   a   y   m   e   n   t       J   o   u   r   n   a   l
0000320   R   e   p   o   r   t   _   1   6   0   6   2   0   1   4   .
0000340   t   x   t  \n   T   M   _   I   C   P   _   E   D   W   _   D
0000360   e   t   a   i   l   e   d       P   a   y   m   e   n   t
0000400   J   o   u   r   n   a   l       R   e   p   o   r   t   _   1
0000420   7   0   6   2   0   1   4   .   t   x   t  \n   T   M   _   I
0000440   C   P   _   E   D   W   _   D   e   t   a   i   l   e   d
0000460   P   a   y   m   e   n   t       J   o   u   r   n   a   l
0000500   R   e   p   o   r   t   _   1   8   0   6   2   0   1   4   .
0000520   t   x   t  \n   T   M   _   I   C   P   _   E   D   W   _   D
0000540   e   t   a   i   l   e   d       P   a   y   m   e   n   t
0000560   J   o   u   r   n   a   l       R   e   p   o   r   t   _   1
0000600   9   0   6   2   0   1   4   .   t   x   t  \n   T   M   _   I
0000620   C   P   _   E   D   W   _   D   e   t   a   i   l   e   d
0000640   P   a   y   m   e   n   t       J   o   u   r   n   a   l
0000660   R   e   p   o   r   t   _   2   0   0   6   2   0   1   4   .
0000700   t   x   t  \n   T   M   _   I   C   P   _   E   D   W   _   F
0000720   I   N   0   4   -   A   C   C   O   U   N   T   _   C   O   N
0000740   S   O   L   _   2   0   1   4   0   6   1   4   .   c   s   v
0000760  \n   T   M   _   I   C   P   _   E   D   W   _   F   I   N   0
0001000   4   -   A   C   C   O   U   N   T   _   C   O   N   S   O   L
0001020   _   2   0   1   4   0   6   1   5   .   c   s   v  \n   T   M
0001040   _   I   C   P   _   E   D   W   _   F   I   N   0   4   -   A
0001060   C   C   O   U   N   T   _   C   O   N   S   O   L   _   2   0
0001100   1   4   0   6   1   6   .   c   s   v  \n   T   M   _   I   C
0001120   P   _   E   D   W   _   F   I   N   0   4   -   A   C   C   O
0001140   U   N   T   _   C   O   N   S   O   L   _   2   0   1   4   0
0001160   6   1   8   .   c   s   v  \n   T   M   _   I   C   P   _   E
0001200   D   W   _   F   I   N   0   4   -   A   C   C   O   U   N   T
0001220   _   C   O   N   S   O   L   _   2   0   1   4   0   6   1   9
0001240   .   c   s   v  \n   T   M   _   I   C   P   _   E   D   W   _
0001260   F   I   N   0   4   -   A   C   C   O   U   N   T   _   C   O
0001300   N   S   O   L   _   2   0   1   4   0   6   2   0   .   c   s
0001320   v  \n   T   M   _   I   C   P   _   E   D   W   _   F   M   -
0001340   2   3   5   A   _   L   A   P   O   R   A   N   _   R   I   N
0001360   G   K   A   S   A   N   _   T   R   A   N   S   A   K   S   I
0001400   _   B   A   Y   A   R   A   N   _   F   A   M   I   S   _   1
0001420   4   0   6   2   0   1   4   .   t   x   t  \n   T   M   _   I
0001440   C   P   _   E   D   W   _   F   M   -   2   3   5   A   _   L
0001460   A   P   O   R   A   N   _   R   I   N   G   K   A   S   A   N
0001500   _   T   R   A   N   S   A   K   S   I   _   B   A   Y   A   R
0001520   A   N   _   F   A   M   I   S   _   1   6   0   6   2   0   1
0001540   4   .   t   x   t  \n   T   M   _   I   C   P   _   E   D   W
0001560   _   F   M   -   2   3   5   A   _   L   A   P   O   R   A   N
0001600   _   R   I   N   G   K   A   S   A   N   _   T   R   A   N   S
0001620   A   K   S   I   _   B   A   Y   A   R   A   N   _   F   A   M
0001640   I   S   _   1   7   0   6   2   0   1   4   .   t   x   t  \n
0001660   T   M   _   I   C   P   _   E   D   W   _   P   E   L   A   N
0001700   G   G   A   N   _   A   T   D   _   D   A   N   _   A   N   T
0001720   A   R   A   B   A   N   G   S   A   (   O   P   R   )   _   N
0001740   _   0   1   0   6   2   0   1   4   .   c   s   v  \n
0001756

$ cat -evt ftp_list.txt
Code:
TM_ICP_EDWH_FICL_13062014.TXT$
TM_ICP_EDWH_FICL_16062014.TXT$
TM_ICP_EDW_Detailed Payment Journal Report_14062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_15062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_16062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_17062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_18062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_19062014.txt$
TM_ICP_EDW_Detailed Payment Journal Report_20062014.txt$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140614.csv$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140615.csv$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140616.csv$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140618.csv$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140619.csv$
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140620.csv$
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_14062014.txt$
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_16062014.txt$
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_17062014.txt$
TM_ICP_EDW_PELANGGAN_ATD_DAN_ANTARABANGSA(OPR)_N_01062014.csv$
$

So how?

Thank you.
# 4  
Old 06-20-2014
What is the output of
Code:
{ echo "FIRST" ; cat ftp_list.txt ; echo "LAST" ; }

If that looks normal then perhaps there is something fishy in the mail system...
What is your OS and version ?
This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 06-20-2014
Quote:
Originally Posted by Scrutinizer
What is the output of
Code:
{ echo "FIRST" ; cat ftp_list.txt ; echo "LAST" ; }

If that looks normal then perhaps there is something fishy in the mail system...
What is your OS and version ?
It works fine:
Code:
$ { echo "FIRST" ; cat ftp_list.txt ; echo "LAST" ; }
FIRST
TM_ICP_EDWH_FICL_13062014.TXT
TM_ICP_EDWH_FICL_16062014.TXT
TM_ICP_EDW_Detailed Payment Journal Report_14062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_15062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_16062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_17062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_18062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_19062014.txt
TM_ICP_EDW_Detailed Payment Journal Report_20062014.txt
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140614.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140615.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140616.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140618.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140619.csv
TM_ICP_EDW_FIN04-ACCOUNT_CONSOL_20140620.csv
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_14062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_16062014.txt
TM_ICP_EDW_FM-235A_LAPORAN_RINGKASAN_TRANSAKSI_BAYARAN_FAMIS_17062014.txt
TM_ICP_EDW_PELANGGAN_ATD_DAN_ANTARABANGSA(OPR)_N_01062014.csv
LAST

$ uname -a
Code:
HP-UX system1 B.11.31 U ia64 0189138652 unlimited-user license

TQ.

---------- Post updated at 11:34 AM ---------- Previous update was at 11:26 AM ----------

Well, if it is too strange.

Now it works fine with this:
Code:
SUBJECT="CAMELOT-MS Portal Missing Reports"
CONTENT="/EDWH-DMT02/script/CAMELOT/ftp_list.txt"
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com" "$SUBJECT" "$CONTENT"

email_v1.sh
Code:
# Author: Mohd Suhaimi Shariff
# Template for HTML E-mail
# 1st creation: Friday, May 18, 2012 04:07:14 PM

export MAILTO="$1"
export SUBJECT="$2"
export CONTENT="$3"
(
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo '<HTML><BODY><PRE>'
 cat $CONTENT
 echo '</PRE></BODY></HTML>'
) | /usr/sbin/sendmail $MAILTO

But how do I send e-mail to multiple recipients just using the same below command
Code:
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com" "$SUBJECT"

Thank you.
# 6  
Old 06-20-2014
I've encountered this issue with outlook mail clients before.

Try putting a couple of spaces in the front of every line:

Code:
{ echo "  FIRST" ; sed 's/^/  /' ftp_list.txt ; echo "  LAST" ; } | /usr/bin/mailx ...

This User Gave Thanks to Chubler_XL For This Post:
# 7  
Old 06-20-2014
Quote:
Originally Posted by Chubler_XL
I've encountered this issue with outlook mail clients before.

Try putting a couple of spaces in the front of every line:

Code:
{ echo "  FIRST" ; sed 's/^/  /' ftp_list.txt ; echo "  LAST" ; } | /usr/bin/mailx ...

Thanks a lot!

That fix the issue right away!

But I still want to know about the one line command for my previous question.

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Manipulate condition to send mail based on output text in file

Hi All, I have a working script as below. echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies

2. UNIX for Dummies Questions & Answers

Merge two text files by two fields and mixed output

Hello, I'm back again looking for your precious help- This time I need to merge two text files with matching two fields, output only common records with mixed output. Let's look at the example: FILE1 56153;AAA0708;3;TEST1TEST1; 89014;BBB0708;3;TEST2TEST2; 89014;BBB0708;4;TEST3TEST3; ... (7 Replies)
Discussion started by: emare
7 Replies

3. Shell Programming and Scripting

How to merge lines based off of text?

Hello Everyone, I have two files, similar to the following: File 1: 8010 ITEM01 CODE1 FLAG1 filler filler 7020 OBJECT CODE2 FLAG2 filler 6010 THING1 CODE4 FLAG4 6011 ITEM20 CODE7 FLAG7 File 2 contains: 6020 ITEM01 CODEA FLAGA filler filler filler 7000 OBJECT CODEB... (2 Replies)
Discussion started by: jl487
2 Replies

4. Shell Programming and Scripting

remove blank lines and merge lines in shell

Hi, I'm not a expert in shell programming, so i've come here to take help from u gurus. I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command. I've a datatable csv of the below format - --in file format xx,xx,xx ,xx , , , , ,,xx, xxxx,, ,, xxx,... (11 Replies)
Discussion started by: dvah
11 Replies

5. Shell Programming and Scripting

Merge lines in text file based on pattern

Hello, I have searched forum trying to find a solution to my problem, but could not find anything or I did not understand the examples.... I should say, I am very inexperienced with text processing. I have a text file with approx 60k lines in it. I need to merge lines based on the number... (8 Replies)
Discussion started by: Bertik
8 Replies

6. Shell Programming and Scripting

Merge lines in a file with Awk - incorrect output

Hi, I would like: FastEthernet0/0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 output errors, 0 collisions, 0 interface resets Serial1/0:0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 0... (14 Replies)
Discussion started by: mv652
14 Replies

7. Shell Programming and Scripting

Add text before lines in command output

Hi2all, I have following command in IBM HMC console: lssyscfg -r prof -m Server-9117-MMA-SN655D350 -F lpar_name,min_mem,desired_mem --header which gives me the following output: lpar_name,min_mem,desired_mem lpar1,1024,2048 lpar2,1024,2048 lpar3,2048,4096 What I want is to add in... (3 Replies)
Discussion started by: UsRb
3 Replies

8. Shell Programming and Scripting

need to search text and output previous lines

I have a file (OMlog0) that is quite large, I need to find the line "Automatic Recharge Audit Process Finished" and output that line and the time stamp that occurs two lines previous. The line that I was using is "sed -n '/Automatic Recharge Audit Process Finished/,/No errors/p' /sn/log/OM* >... (8 Replies)
Discussion started by: grinds
8 Replies

9. Shell Programming and Scripting

Cronjob - Redirect mail output to file, LINES & COLUMNS

I currently have an expect script that issues the 'mail' command and sends an 'x' when it receives the & prompt from mail to quit. The expect script is able to do stty rows 100 columns 200 < $spawn_out(slave,name) to set up the number of columns and rows. I would like to get rid of the expect... (0 Replies)
Discussion started by: jharvey
0 Replies

10. Shell Programming and Scripting

mail merge

dear friends plese give me full shell script for mail merge facilityu. i.e. to create a letter file i.e to create data file and report maile merge using shell scripitng. when run the programme ask for fields and store in a file and from another program when run that mail merge file... (3 Replies)
Discussion started by: cvvsnm
3 Replies
Login or Register to Ask a Question