Hi Experts,
how to pass subject,mailbody and filename as parameters to function.
mode=$1
file=/db/files/uniq.txt
mail_send() {
export MAILPART=$(uuidgen)
export MAILPART_BODY=$(uuidgen)
{
echo "TO:nalu.d@hes.com"
echo "Subject:$subject"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
echo "--$MAILPART"
echo ""
echo "Hi"
echo "$subject"
echo ""
cat $file
echo ""
echo "*****END*****"
} | /usr/sbin/sendmail -t
}
In the below case I want send an email "Incorrect path".
I don't want to send the file(file=/db/files/uniq.txt).
Issue: It's sending the file as well .
check=$(ls -d ${path} | wc -l )
if [[ $check -eq 0 ]]; then
subject="Incorrect path"
mail_send $Subject $subject
exit 0
fi
if [[ $mode -eq 1 ]]
then
mcount=0
day_count=0
while [[ $bback -ne 0 ]]; do
finalFormat=$(echo "$finalFormat" | sed -r 's/[H]+//g;s/_*$//g;s/%*$//g;s/-*$//g')
start=`date +${finalFormat} -d "$bback day ago"`
mcount=`expr $mcount + 1`
file_name="${start}"
printf "$file_name\n"
fi
bback=`expr $bback - 1`
done >>$file
if [[ $mode -eq 2 ]]
then
mcount=0
day_count=0
while [[ $bback -ne 0 ]]; do
finalFormat=$(echo "$finalFormat" | sed -r 's/[HMS]+//g;s/_*$//g;s/%*$//g;s/-*$//g')
start=`date +${finalFormat} -d "$bback month ago"`
mcount=`expr $mcount + 1`
file_name="${start}"
printf "$file_name\n"
fi
bback=`expr $bback - 1`
done >>$file
Requirement : mail should send the file(/db/files/uniq.txt) and based on the mode subject has to be changed.
Issue: Always it's send same subject.
If mode is 1 subject should be commerce file .If mode is 2 subject should be economics file
if [[ $missing_count -gt 0 ]]; then
mail_send $Subject $subject $file
fi
In the file(/db/files/uniq.txt) data is as below
201704-12
201704-11
201704-23
Issue: In the mail it's coming as 201704-12201704-11201704-08.
Even if I add it as attachment same issue.
Please help me.
Thanks in Advance.
---------- Post updated at 07:52 AM ---------- Previous update was at 03:22 AM ----------
Hi All,
I have fixed all other could you please help me on this piece.
I am unable to fix.
In the file(/db/files/uniq.txt) data is as below
201704-12
201704-11
201704-23
Issue: In the mail it's coming as 201704-12201704-11201704-08.
Even if I add it as attachment same issue.
Thanks in advance.