lundi 6 mai 2019

If clauses not working as expected in unix

I am struggling with my unix script to send mail from success.log and failure.log.

With my current script and the changes i am making, either success mail is coming or failure mail is coming DB_Success_log has all the Database which successfully got processed. DB_Failure_log has ll the Databases which failed. Below is just skeleton of my script and not exact script.

DB_Success_log=path/DB_succes.log
DB_Failure_log=path/DB_failure.log
mail_content=path/mail_content.mail


if [-f "$DB_Success_log" ] ; then
echo " From :$from
To : $to
cc : $cc
Subject : $subject

Below Db got success  >$mail_content
cat $DB_Success >>$mail_content

if [-f "$DB_failure_log" ] ; then
echo " From :$from
To : $to
cc : $cc
Subject : $subject

Below DB got failed  >$mail_content
cat $DB_Failure >>$mail_content

cat $mail_content |sendmail -t

in the above two only one is running. If out of 10 dbs 5 are failing 5 are success then either only failing mail is coming with the list or success is coming. I tried to change my If clause but it didn't help.

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire