Sending an Automated Mail with a Condition

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending an Automated Mail with a Condition
# 15  
Old 12-05-2013
This is not the entire script's log, but it shows at least how the central conditional expression is looped through
+ [[ 05 -eq 05 ]]
+ [[ Thu = Thu ]]
+ [[ Dec = Dec ]]             # all three conditions TRUE --> print name
+ [[ 05 -eq 05 ]]
+ [[ Thu = Thu ]]
+ [[ December = Dec ]]        # third cond. failed, next loop iteration
+ [[ 06 -eq 05 ]]             # first cond. failed, skip rest, next iteration

So - there should be only one name printed to the output file.
# 16  
Old 12-05-2013
Originally Posted by Sreenadh
#Initial Variables
#get today's date & month
DAT=`(date '+%d')`
DAY=`(date '+%a')`
MON=`(date '+%b')`
while IFS=',' read name date day month year
set -x
if [ "$date" -eq "$DAT" -a "$day" = "$DAY" -a "$month" = "$MON" ]
set +x
   then echo $name
done < $IFILE > $OFILE
set -x
if [ -f $OFILE -a -s $OFILE ]
set +x
   sed -i '1i The following users celebrate their birthday:\n' $OFILE
   mailx -s "Birthday on: $DAT" $MAILID  < $OFILE
  # \rm $OFILE
   echo "Birthday mail sent"
   echo "No birthdays today"

This is the code i am executing & i am trying this in my office, dont have bash here! Smilie

---------- Post updated at 08:08 AM ---------- Previous update was at 08:04 AM ----------

---------- Post updated at 08:09 AM ---------- Previous update was at 08:08 AM ----------

Tried this IF condition buddy, but still the result is same Smilie
Is it because i am executing it in Ksh ? i cant do it in bash though!

u can go through the below link for more on if conditions hope u can find a way out
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

2. Shell Programming and Scripting

if condition in sending mail

hello Gurus i have tp tackle a condition like below I have two files to check for any data in it apart from header if one of the file has data I have to send mail given the file name So far my code is if || ; then (printf "%s\n%s\n" "Please check the below bad files: "... (2 Replies)
Discussion started by: Pratik4891
2 Replies

3. Shell Programming and Scripting

Stop sending mail after certain number of mail

Hi guys... I am busy writing a script to notify me via an mail if my application is down. I have done that. Now I want this script to stop sending mails after five mails were sent but the script should keep on checking the application. When the application is up again that count should be... (5 Replies)
Discussion started by: Phuti
5 Replies

4. UNIX for Dummies Questions & Answers

sending mail

i want to send an email from the unix machine to the windows machine. now windows dont have any specified folder for the mail. mail has to be sent to the email-id like unix machine itself can not directly send mail. it has to be transferred via mail server. (11 Replies)
Discussion started by: parmeet
11 Replies

5. Filesystems, Disks and Memory

Sending mail

Hi, I am want to send mails from my aix server using smtp adaptors.How to configure this? i tried with send mail command but it is failing,but what i try with my localhost(my desktop which is not using the aix server) machine i can send mails using the smtp adaptor(simply type telnet... (0 Replies)
Discussion started by: gnanadurai_it
0 Replies

6. HP-UX

hp ux not sending mail

Hi.. In Hp ux box,, mails are not being sent. they are getting queued up in mail queue. (3 Replies)
Discussion started by: kkhan
3 Replies

7. HP-UX

Sending mail thru HP-UX

I got stuckup with the issue of sending mail with attachment from HP-UX. Can any one please help me in resolving the issue. I am giving the criteria which i want below, 1. To address. 2. Cc address. 3. Subject 4. File attachment(the file i am using is :-- filename_`date +%Y%m%d`.CSV)... (1 Reply)
Discussion started by: medisetti
1 Replies

8. UNIX for Dummies Questions & Answers

Sending Mail

Please help me out i want to know how to send email from unix machine to any email-id. mail to be sent is web based mail. (1 Reply)
Discussion started by: parmeet
1 Replies

9. UNIX for Advanced & Expert Users

sending mail

How do I send an email with a subject and an attachment from a command prompt? (3 Replies)
Discussion started by: mskarica
3 Replies

10. UNIX for Dummies Questions & Answers

sending a mail to a mail client

Hi everyone! I'm trying to create a database monitoring script that reads an alert file and sends an error message if it can 'grep' a particular string. Is there a way to send this message to a mail client using SMTP? Even better, is there any place on this site that has these kinds of... (5 Replies)
Discussion started by: solaris73
5 Replies
Login or Register to Ask a Question