To send mail with same format as in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To send mail with same format as in file
# 1  
Old 01-11-2013
To send mail with same format as in file

I want to send the content in same format as it is in file.

Code:
#!/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


Last edited by joeyg; 01-11-2013 at 03:24 PM.. Reason: Please wrap commands and data with CodeTags
# 2  
Old 01-11-2013
Not sure I understand

There are many posts on this site referring to sending mail with attachments. Such as:
https://www.unix.com/unix-dummies-que...ll-script.html

Also, use the Search function on the main toolbar to look for more.
# 3  
Old 01-11-2013
Mail format should be same as the format in file

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..

Code:
 
Asia 5.2
Europe 7.2
North America 5.5

than the mail should have the same format as

Code:
 
Asia 5.2 2.1
Europe 7.2 4.1
North America 5.5 1.1


but my program is giving output as

Code:
 
Asia 5.2 2.1 Europe 7.2 4.1 North America 5.5 1.1


Last edited by Scott; 01-15-2013 at 11:33 AM.. Reason: Code tags
# 4  
Old 01-11-2013
Change the Content-Type to text/plain and re-try:
Code:
echo "Content-Type: text/plain"

# 5  
Old 01-11-2013
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.
# 6  
Old 01-15-2013
It worked

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

Code:
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)

Code:
ABC Asia 5.2
ABC Europe 7.2
ABC North America 5.5

than the mail should have theformat as

Code:
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

Code:
 
ABC gzip -dc /var/opt/home/smith/buffer.gz /opt/smith.gz (Asia)|(Europe)|(North America)


Last edited by Scott; 01-15-2013 at 11:33 AM.. Reason: Code tags
# 7  
Old 01-15-2013
Use awk to skip the first line and print:
Code:
awk 'NR>1' filename

Or use awk to remove line containing pattern gzip
Code:
awk '!/gzip/' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Programming

How to send a file in e-mail from on Linux C++?

Hi ! I-m copile from source a C++ program from tutorials from internet. I don't understendig any programing languages.. but compiled aplication running ok. I-ts possible to add in my used program, lines to send one file from config directory in e-mail, to my e-mail adress ? I want to run... (2 Replies)
Discussion started by: kraftwerk
2 Replies

3. Shell Programming and Scripting

Mailx command - send mail as table format

I have to send a couple of rows that have been returned from a SQL query. I have written the output of the query to a file and while i try to print this in the mail body the formatting goes wrong. Intended Output in mail body: Col1 Col2 Col3 ------ ... (2 Replies)
Discussion started by: qwertyu
2 Replies

4. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

5. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

6. UNIX for Dummies Questions & Answers

How to send file in mail

Hi I want to send out a file that generate 1st of each month that have formate like this 11012008_experience_rate_log.txt Now I have setup a cronjob that usually sent this file in mail like cat /data02/transfer/*_experience_rate_log.txt | mail -s 'PICS EXP RATE Logs' lger@bd.com So how... (3 Replies)
Discussion started by: vishalpatel03
3 Replies

7. UNIX for Advanced & Expert Users

how to send file as attachment with mail ?

hello , i m new to linux/unix , well in my college their is linux server to which we all (i and my frnds) login , we can send mail to each other through command "mail" . but any one can tell me how can i attached a binary file with mail. we are using red hat , "pine ", "mailx" , all... (2 Replies)
Discussion started by: alert_every1
2 Replies

8. Shell Programming and Scripting

Pull E-mail address from file, send e-mail

Hello, I am new to perl and need to create a script that will read a file and pull a name from the file and send e-mail. How can I use the following awk statement in a perl script? grep UNIXadmins /root/mail.conf | awk '{ print $2}' and use the output to send a e-mail. Any help would... (1 Reply)
Discussion started by: DC Heard
1 Replies

9. UNIX for Dummies Questions & Answers

To send a mail with a file attached

Hi, Can anyone please tell me how to send a mail to a person in unix with a file attached. The file need to be zipped and then i want to send the mail to a person. I know that we can able to send mail from unix using the command mail mailaddress to send a mail to a person with the... (5 Replies)
Discussion started by: samudha
5 Replies

10. UNIX for Dummies Questions & Answers

Send text file to mail

I have a utility that opens a telnet session and allows me to execute commands through a script. The utility allows me to output to a text file whatever is outputted to screen. This utility runs from a DOS prompt in Windows 95/98, NT or 2000. How can I mail text file this to a certain user. I... (2 Replies)
Discussion started by: petrosi
2 Replies
Login or Register to Ask a Question