Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send email to subscribers in a file

Status
Not open for further replies.

761210

IS-IT--Management
Jun 25, 2003
13
0
0
US
Guys,

I am having problem reading from a subscriber's file to send out email according. Below is my codes:

###################### Subscribers File ##################
mohd.ali@linux.net
mtyson@linux.net
hiroka@linux.net
##################### end ##################################

Above file is saved as mail.sub

then i have another file, query.sh, which contains a while loop that reads line by line of mail.sub file to determine information of users in a Oracle database. Here's the code:

############################################################
while read line;
do
echo "$line"
user=`echo ${line} | awk '{print $1}'`;

sqlplus -s test/test @extract_user_info $user;

echo " This is a testing " > mailbody.$user

mailx -s &quot;User info for $user&quot; ${user} < mailbody.$user;
fi

done

##################### end ##################################

in order to execute the code, I type in:
$cat mail.subs | query.sh
However, I am only able to get the 1st email send out. The remaining two users does not get executed. I am wondering what is going on? Any one to enlighten me?
 
while read line;
do
echo &quot;$line&quot;
#why this line? username in '$line' should already be ok
user=`echo ${line} | awk '{print $1}'`;

sqlplus -s test/test @extract_user_info $user;

echo &quot; This is a testing &quot; > mailbody.$user

#why semicolon?
mailx -s &quot;User info for $user&quot; ${user} < mailbody.$user;
#shouldn't be here at all
fi

done
 
Perhaps something like this would be shorter:

MAILLIST=`cat mail.sub`
for i in $MAILLIST
do
sqlplus -s test/test @extract_user_info $i
echo &quot; This is a test&quot;|mailx -s &quot;User info for $i&quot; $i
done

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top