Register
It is currently Mon Oct 20, 2014 3:39 am

Help with mail script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Apr 30, 2014 1:48 pm   

Joined: Wed Apr 30, 2014 1:37 pm
Posts: 2
Hi,

I am writing a simple script to send emails using mail command.
The problem is: I want it to, when given -A argument, send multiple mails to recipients listed as -A following arguments. Each recipient receives a mail containing text from adr(recipient_nr).txt

Code:
i=`expr "$#" - 1`
j="$#"
if [ "$1" = "-A" ]
then
while [ "$i" != 0 ]
do
mail -s test_sub ? < adr$i.txt
#                    ^
#tried a few things there but couldn't make it work...
cat adr$i.txt >> arch.txt
rm adr$i.txt
(( i-- ))
(( j-- ))
exit

done
fi



Some parts of the code might be leftovers after experimenting with it.


Top
 Profile  
 PostPosted: Wed Apr 30, 2014 8:19 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
hi,

Code:
if test "$1" = "-A"
then
   while test $# -gt 1
   do 
      shift
      mail -s test_sub "$1" < adr$#.txt
      cat adr$#.txt >> arch.txt
      rm adr$#.txt
   done
fi


Top
 Profile  
 PostPosted: Thu May 01, 2014 12:03 am   

Joined: Wed Apr 30, 2014 1:37 pm
Posts: 2
Watael wrote:
hi,

Code:
if test "$1" = "-A"
then
   while test $# -gt 1
   do 
      shift
      mail -s test_sub "$1" < adr$#.txt
      cat adr$#.txt >> arch.txt
      rm adr$#.txt
   done
fi


Thanks, works great! ;)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP