LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2007, 08:16 AM   #1
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Rep: Reputation: 15
mail via unix troubling


I wrote the following code to send a mail and return a status of 1.

Code:
EMAIL_MSG=`cat message.txt` 
mailx -s "${THIS_SCRIPT} $finished." $EMAIL_USERS <<EOF 
Shell script : ${THIS_SCRIPT} 
${EMAIL_MSG}
EOF 


exit 1

Everything works fine except that the message body of the mail also contains

EOF

exit 1
 
Old 05-03-2007, 08:22 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
this should work:
Code:
mailx -s "${THIS_SCRIPT} $finished." $EMAIL_USERS <<EOF 
Shell script : ${THIS_SCRIPT} 
$(cat message.txt)
or
`cat message.txt`
EOF

Last edited by bigearsbilly; 05-03-2007 at 08:24 AM.
 
Old 05-03-2007, 08:59 AM   #3
radoulov
Member
 
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212

Rep: Reputation: 38
Quote:
Originally Posted by tostay2003
I wrote the following code to send a mail and return a status of 1.

Code:
EMAIL_MSG=`cat message.txt` 
mailx -s "${THIS_SCRIPT} $finished." $EMAIL_USERS <<EOF 
Shell script : ${THIS_SCRIPT} 
${EMAIL_MSG}
EOF 


exit 1

Everything works fine except that the message body of the mail also contains

EOF

exit 1
Remove the space after both "EOF"'s.

It could be also:

Code:
printf "%s\n" "Shell script : ${THIS_SCRIPT}" "$(<message.txt)"|
mailx -s "${THIS_SCRIPT} $finished." "$EMAIL_USERS"
Or, with bash:
Code:
mailx -s "${THIS_SCRIPT} $finished." "$EMAIL_USERS"\
< <(printf "%s\n" "Shell script :${THIS_SCRIPT}" "$(<message.txt)")
 
Old 05-03-2007, 09:35 AM   #4
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Original Poster
Rep: Reputation: 15
removing spaces helped. Thanks a lot
 
  


Reply



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
How to use pine for unix move mail? anupamsr Linux - Software 0 05-10-2006 09:05 AM
pop3 and smtp with unix mail d4nr Linux - Software 0 11-15-2004 12:58 PM
Retrieving Unix mail with Opera ? jfi Solaris / OpenSolaris 2 04-30-2004 08:21 AM
Where is traditional unix 'mail' ? John Velman Slackware 2 01-24-2004 12:39 PM
migrating unix mail to linux karwoski Linux - Software 1 12-04-2003 10:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:49 AM.

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
Open Source Consulting | Domain Registration