LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-01-2010, 05:32 AM   #1
danishgambit
LQ Newbie
 
Registered: Sep 2009
Location: glasgow, scotland
Posts: 25

Rep: Reputation: 0
mailx script using unspecified recipients


Morning all,

Red Hat.
bash script.

I know there are several posts to do with mail and mailx, but nothing obvious in terms of my problem. Below is a small excerpt from the script that runs, but seems to have developed a problem.


###### Email Parameters ######
RECIPIENTS="name1@domain"
SUBJECT="${HOSTNAME} Subject Line"
....
###### EMAIL SUPPORT ######
EMAIL_SUPPORT() {
sleep 30
mailx -s ${SUBJECT} ${RECIPIENTS} < ${log}
}
....
EMAIL_SUPPORT
....

The email is sent, but with numerous recipients, rather than the one specified in the RECIPIENTS variable, and because most of these aren't
valid, getting a dead.letter. I've put in some debugging to check values of recipient and subject, and they show as expected. Any ideas?.

TIA,

DG.
 
Old 03-01-2010, 07:37 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I don't know why you're using ${variable}, why not just $variable ?
I can understand ${HOSTNAME} as it is command substitution, but the subject and recipients are pre-defined variables.
So just use :
Code:
mailx -s "$SUBJECT" "$RECIPIENTS" < ${log}
Notice the double quotes.

Last edited by smoker; 03-01-2010 at 07:58 AM.
 
Old 03-01-2010, 07:46 AM   #3
danishgambit
LQ Newbie
 
Registered: Sep 2009
Location: glasgow, scotland
Posts: 25

Original Poster
Rep: Reputation: 0
Afternoon Smoker,

thanks for that. Worked fine. I'd thought initially that using quotes in the variable definitions would have done the trick, but seems obvious now that it wouldn't work as there are spaces in the $SUBJECT string.

Regards,

DG.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sending mails in script using mailx fails kais1 Linux - Newbie 2 07-26-2009 11:40 PM
Kmail duplicate recipients Zelator Ubuntu 2 01-17-2007 02:41 AM
Adobe Flash Player Multiple Unspecified Vulnerabilities (Highly Critical) win32sux Linux - Security 2 09-13-2006 08:48 AM
Unspecified number of arguments. ArthurHuang Programming 2 05-30-2006 09:54 PM
Flash Player Unspecified Code Execution Vulnerabilities (Highly Critical) win32sux Linux - Security 1 03-14-2006 09:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration