I want to send the content in same format as it is in file.
#!/bin/sh
cat /usr/test/abc > /usr/test/abc/file
if [ -s /usr/test/abc/file ]
then
MAILTO=test@yahoo.com
CONTENT="/usr/test/abc/file"
(
echo "Subject: TEST "
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
cat $CONTENT
) | /usr/sbin/sendmail -t $MAILTO
else
echo "bbb"
fi
joeyg
January 11, 2013, 2:29pm
2
There are many posts on this site referring to sending mail with attachments. Such as:
Hi Guys, I have written a script to send some .csv files to my client.The script work fines and they receive file correctly.But,The problem is the file name is changed to "attachment" from & | The UNIX and Linux Forums
Also, use the Search function on the main toolbar to look for more.
I dont want to attch the file but it want to cat the content and send them in same format example
if file has data..
Asia 5.2
Europe 7.2
North America 5.5
than the mail should have the same format as
Asia 5.2 2.1
Europe 7.2 4.1
North America 5.5 1.1
but my program is giving output as
Asia 5.2 2.1 Europe 7.2 4.1 North America 5.5 1.1
Yoda
January 11, 2013, 3:30pm
4
Change the Content-Type to text/plain
and re-try:
echo "Content-Type: text/plain"
joeyg
January 11, 2013, 3:35pm
5
Sounds like a cr/lf (carriage return & line feed) issue common when sharing files between unix and other systems.
There are utilities that will correct for this.
Also, I know that I sometimes get different views of the same unix-created file if I open with Windows Notepad or Wordpad.
Thanks a lot bipin it worked.
---------- Post updated 01-15-13 at 09:47 AM ---------- Previous update was 01-14-13 at 11:08 AM ----------
How to remove unwanted information from the file and send over the mail.
file has below details
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)
ABC Asia 5.2
ABC Europe 7.2
ABC North America 5.5
than the mail should have theformat as
ABC Asia 5.2 2.1
ABC Europe 7.2 4.1
ABC North America 5.5 1.1
I want to remove the line mentioned below when sending over e-mail
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)
Yoda
January 15, 2013, 9:52am
7
Use awk to skip the first line and print:
awk 'NR>1' filename
Or use awk to remove line containing pattern gzip
awk '!/gzip/' filename
thanks a lot Bipin below mnetioned commad worked
awk '!/gzip/' filename
but the other one awk 'NR>1' filename does not worked my file had data mentioned below and i wanted to remove gzip line from all.
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)
ABC Asia 0.2 1 0
ABC Europe 6.2 2 1
ABC North America 1.5 2 1 1
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)
ABC Asia 1.2 0 1 1
ABC Europe 3.2 1 1 1
ABC North America 2.5 1 1 1
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)
ABC Asia 1.2 0 1 1 3 3 3 3
ABC Europe 3.2 1 1 1 3 3 3 3
ABC North America 2.5 1 1 1 3 3 3 3