The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to send a mail using elm in cc list? svenkatareddy SUN Solaris 0 03-03-2008 06:19 AM
How to send a mail using elm in cc list? svenkatareddy Shell Programming and Scripting 0 03-03-2008 04:41 AM
Regarding mailing to a distribution list (DL) using mail/mailx command naren_0101bits Shell Programming and Scripting 1 02-06-2008 09:25 AM
want to mail a list of files in different servers AshishK UNIX for Advanced & Expert Users 1 10-07-2007 12:23 PM
mailx and mail list help - newbie qustion HikerLT UNIX for Dummies Questions & Answers 1 02-09-2004 09:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-23-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
Question Mail Receipient List

hi
I am having a shell script that will send the report as an attachment to the number of receipients.
There are chances that these receipients keep on chaging frequently. So I was thinking of some way by which I need not hard code the receipients in the shell script. Instead if i can put them into a file and read the file to get names of receipients . but not able to achive this in shell script. It will of great help for me if somebody can help me with code. ( I am pretty new to shell scripts)

Many thanks
Reply With Quote
Forum Sponsor
  #2  
Old 11-23-2005
Registered User
 

Join Date: Sep 2005
Location: Chennai
Posts: 80
You can try creating (or adding to, if you have one) a .mailrc file in which you may define mail groups.
Reply With Quote
  #3  
Old 11-23-2005
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
try this,

for the frequently changing address entries you can have it in a file
and for any future changes you can just change the file entry :<mail.address.entries>
you neednt revisit the script

to send a particular file as body of the mail
Code:
mailx -s "<your subject>" "`cat <mail.address.entries>`" < <file_to_be_sent>
to send a particular file as attachment
Code:
uuencode <source_file> <decoded_path_name> | mailx -s "<your subject>" "`cat <mail.address.entries>`"
Reply With Quote
  #4  
Old 11-23-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
Mailing List

thanks for the solution.
have another doubt how do i list the receipients names in the address file?
whether they should be comma separated or semi colon or something else ?
Reply With Quote
  #5  
Old 11-24-2005
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
a simple file listing like this with each address entries in a line
would do

>cat mail.address
abc@xyz.com
eft@erg.com
afhs@ert.com
>
Reply With Quote
  #6  
Old 11-24-2005
Registered User
 

Join Date: Nov 2005
Posts: 4
hi
here is my address file
> cat mail.address
abc@gmail.com
xyz@mailserver.com

===
script code
==
> cat mail.sh
#!/bin/ksh
SPOOLFILE=pk_comp_tools.sh
echo "Send the E-mail message..."
mail -s "$SUBJECT" "`cat mail.address`" <<EOF
Please find the report attached.
`cat $SPOOLFILE | uuencode $SPOOLFILE`
EOF
==
==
this is sending mail to only first address and second address is being displayed as part of mail body. I tried giving the address in "mail.address" by separating them using comma. but still the mail is going to first person only.
Reply With Quote
  #7  
Old 11-24-2005
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
i have modified ur script ...

and use mailx
please try this and let me know

Code:
#!/bin/ksh
SPOOLFILE=pk_comp_tools.sh
echo "Send the E-mail message..."
(echo "Please find the report attached." ; uuencode $SPOOLFILE $SPOOLFILE.txt ) | mailx -s "$SUBJECT" "`cat mail.address`"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux, mailx, mailx attachment

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0