LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2011, 05:10 AM   #1
ananthkadalur
Member
 
Registered: Mar 2011
Posts: 38

Rep: Reputation: 0
whole file content is coming in subject


Hi...I am trying to send a logfile details to my mail ID, For that I have made a shell script. for example plz see the below

#!/bin/bash
admin1=someone@something.com
cd /tmp
echo Testing mail transfer > /var/log/backup/test
echo These are my files >> /var/log/backup/test
ls -ltrh >> /var/log/backup/test
cd /var/log/backup
mail -s "$(cat test)" $admin1 << END
END

It is working fine in cent OS, I mean, the first line of the file will be in subject box & remaining will be in the body, thats what I need.
But in ubuntu10.04 if I execute the same file, I will get the mail. but whole file content is coming as subject & only two or three words can be read. So plz tell me how can I modify the shell script to consider the first line of a file as subject & remaining as body.
 
Old 07-29-2011, 05:29 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well seeing as "-s" is for the subject, that's meant to happen. Pipe the contents into mail (cat test | mail -s "Actual subject here" email@address.com)
 
1 members found this post helpful.
Old 07-29-2011, 07:00 AM   #3
ananthkadalur
Member
 
Registered: Mar 2011
Posts: 38

Original Poster
Rep: Reputation: 0
whole file content is coming in subject

Hi...
Thank You very much for your quick reply. in the end of the file I showed as below. It is working fine now
(cat test | mail -s "subject" emailaddress)
once again Thank you very much.


Quote:
Originally Posted by acid_kewpie View Post
well seeing as "-s" is for the subject, that's meant to happen. Pipe the contents into mail (cat test | mail -s "Actual subject here" email@address.com)
 
Old 07-30-2011, 02:52 AM   #4
ananthkadalur
Member
 
Registered: Mar 2011
Posts: 38

Original Poster
Rep: Reputation: 0
whole file content is coming in subject

Hi...Iadded as "(cat filename | mail -s "subject" emailaddress)" in the end of the shell script in two of the server. Those are sending mail. But one of the server(ubuntu9.04) is not sending mail. If I see the echo status, it is showing '0' after manually executing that shell script, but mails are not coming. Can anybody help me what all the basic things need to be checked.

Quote:
Originally Posted by ananthkadalur View Post
Hi...
Thank You very much for your quick reply. in the end of the file I showed as below. It is working fine now
(cat test | mail -s "subject" emailaddress)
once again Thank you very much.
 
Old 07-30-2011, 03:14 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Are you actually executing this as subprocess? (in parenthesis)?
 
Old 07-30-2011, 03:31 AM   #6
ananthkadalur
Member
 
Registered: Mar 2011
Posts: 38

Original Poster
Rep: Reputation: 0
whole file content is coming in subject

No. I have added shell script to monitor log files of backup, etc. That is warking fine & getting mails from two of the server. And added same shell script to another one server. path and every thing is correct. but mails are not coming. So I executed it manually and checked the echo status and found '0'. But mails are not coming from that. So I am asking, what are the basic things has to be checked in ubuntu 9.04 server regarding to send mails.

Quote:
Originally Posted by Tinkster View Post
Are you actually executing this as subprocess? (in parenthesis)?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dividing content of one file by content of another larspend Linux - Newbie 5 04-12-2011 09:00 PM
what code would send a file w/ a subject in k shell simsuser Linux - Newbie 4 12-15-2009 04:19 AM
sendmail with file subject and sender name Elnegro8 Linux - Server 1 01-05-2009 09:47 AM
Need content filtering... (sensitive subject) fannymites Linux - Security 5 03-03-2006 05:49 PM
Subject:Passing a text file in Redhat 9 to honeyd james_cwy Linux - Security 7 11-11-2003 12:56 AM


All times are GMT -5. The time now is 01:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration