Re: Export data in order to use it as a variable in shell
Posted in 2000
Are you trying to send a list of all the email-addresses to each address ?
If so, you could change the mailx line to:
for X in `cat report.txt`
do
mailx -s "Report" `echo $X | cut -d\\| -f1`@host <report.txt
done
Or, even:
ADDR=
for X in `cat report.txt`
do
ADDR="${ADDR} `echo $X | cut -d\\| -f1`@host"
done
mailx -s "Report" $ADDR <report.txt
BUT, I guess what you really want is more like this:
dbaccess account <<X 2>/dev/null | grep "@" |&
SELECT TRIM(sales_code) || "@host"
FROM account
X
while read -p ADDR
do
mailx -s "Report" $ADDR <someotherfile.txt
done
>>> "Ilhan Erden" <ilerden@ea-dc.dhl.com> 11/22 9:31 am >>>
Hi Gurus
I have a new challenge.
There is a sales_code data field in the database which includes
data which again I want to use as a variable in the e-mail address.
The script should be something like :
---------------------------------------------------------
$INFORMIXDIR/bin/dbaccess account 2>/dev/null 1>&2 <<!
unload to report.txt
SELECT sales_code
FROM account!
mailx -s "Report" sales_code@host < report.txt
---------------------------------------------------------
Thanks in advance...
Ilhan Erden