LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scheduler Script (https://www.linuxquestions.org/questions/linux-newbie-8/scheduler-script-873127/)

anishkumarv 04-05-2011 10:01 AM

scheduler Script
 
Hi,

My requirement is i want to send mails from server to all my employess with one attachment file for every monday and friday like scheduler.. how it is possible through bash script. please guide me..

zordrak 04-05-2011 11:03 AM

http://www.zedwood.com/article/103/b...-an-attachment

Then use cron to schedule execution of the script.

anishkumarv 04-05-2011 12:36 PM

Hi zordrak,

Mail is not a prob but...i need to send same attachment to N number of mail ids for example


if i have 3 mail ids means

07anis@gamil.com
anish@gamil.com
kumar@gmail.com

at the same time i need to send mail from server to this 3 mail ids.


i think using script we can do that..

like we need to assign all the mail ids store into one file form that we need to get input..that code only i am searching how to do that process...if you have any idea means please share..

vikas027 04-05-2011 12:41 PM

Hi Anish,

You can put all emailIDs in a file say email.txt and use this code
Code:

for i in `cat email.txt`;
do
mutt -s "Your Suject" -a "/your/attachement" $i > /dev/null
done;

Note: Always mention your OS and version when post a query.

anishkumarv 04-05-2011 07:04 PM

Hi vikas
Code:

#!/bin/bash
#### SCHEDULER ####
date=$(date +%d-%m-%y)
for i in `cat mail.txt`;
do
mutt -s "Task Scheduler" -a"/root/Desktop/1.png" $i > /dev/null
done;

when i execute this code its not working after this step..

Quote:

++ date +%d-%m-%y
+ date=06-04-11
++ cat mail.txt
+ for i in '`cat mail.txt`'
+ mutt -s 'Task Scheduler' -a/root/Desktop/1.png 07anis@gmail.com

vikas027 04-06-2011 04:45 AM

Quote:

Originally Posted by anishkumarv (Post 4315146)
Hi vikas
Code:

#!/bin/bash
#### SCHEDULER ####
date=$(date +%d-%m-%y)
for i in `cat mail.txt`;
do
mutt -s "Task Scheduler" -a"/root/Desktop/1.png" $i > /dev/null
done;

when i execute this code its not working after this step..

Do you have mutt installed ?
Post what errors you are getting and output of below command
which mutt

anishkumarv 04-06-2011 05:47 PM

Code:

#!/bin/bash
#### SCHEDULER ####
date=$(date +%d-%m-%y)
for i in `cat mail.txt`;
do
mutt -s "Scheduler" -a /root/Desktop/1.png $i < /root/message
done;

Hi All
Thanks for your Reply Its Working fine now!!!

vikas027 04-07-2011 04:14 AM

Hi Anish,

Glad you made it.
Please mark this thread as solved.


All times are GMT -5. The time now is 11:38 PM.