0

I am working on media management script for my environment in which I want that I should pick values from file or array for different pool and libraries, run the commands based on those inputs and mail the output based on those commands to a different people.

like, run command based on First pool, first library and then mail to the first person in file/array. or it will be great if it can match the things and need not to depend on serial order.

code is :

pool=(apple Mango Banana)
library=(lib1 lib2 lib3)
Name=(Guru Ravinder Eddy)
Email=([email protected] [email protected] [email protected])
Subject=(India Canada Australia)
for l in "${library[@]}"
do
for p in "${pool[@]}"
do
for n in "${Name[@]}"
do
for e in "${Email[@]}"
do
for s in "${Subject[@]}"
execute a command based on pool and library > file1
and then mail to person one by one based on outputs

Output_File=/home/gsingh/MM/file556
echo "<html>" > $Output_File
echo "<title> Test" >> $Output_File
echo "</title>" >> $Output_File
echo "<body>" >> $Output_File
echo "<table border style="05">" >> $Output_File

while read line
do
        echo "<tr>" >> $Output_File
        echo "<td>" >> $Output_File
        echo $line >> $Output_File
        echo "</td>" >> $Output_File
        echo "</tr>" >> $Output_File
done < "file1.txt"
echo "</table>" >> $Output_File
echo "</body>" >> $Output_File
echo "</html>" >> $Output_File
MAILTO=$e
Subject=Test
[email protected]

cat - ${Output_File} <<EOF | /usr/sbin/sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject:$s
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
EOF
Done
Done
Done

My question is that it's going in infinaite loop and even output is not correct, so trying to find best way to achive it.

3
  • I'm not sure I see any question here. Is there a problem with that script ? If so, by example, what is the wrong output and what is the output it should have instead ? Commented Nov 22, 2019 at 16:41
  • IMHO you have not closed your while loop, ideally if you are reading an Input_file then you should give it like ` done < "Input_file`,which I can't see, try it out in case you are reading an Input_file and let us know then. Commented Nov 22, 2019 at 18:03
  • I have already closed my while loop,(done < "file1.txt") and this mail script i have taken from of your post only. My problem is that I am not able to achieve the things through it. I want that based on values in the file it read, it processes the commands and store its result in file, and the content of the file goes as mail to different people Commented Nov 22, 2019 at 18:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.