Hi,
I am using su within a for loop. As you might expect, it prompts for password during each loop execution. Here is my piece of code:
for i in $LIST
do
if [ `echo $i | grep -c 'APSTAGE'` -gt 0 ]
then
DATABASE=`echo $i | awk -F "|" '{ print $1 }'`
USER_ID=`echo $i | awk -F "|" '{ print $2 }'`
su - apstage -c "echo $i; cd /home/apstage/src/util; . GHD_common.ksh; db_connect -c $DATABASE -u $USER_ID"
fi
done
I tried to put the loop inside su -c but $LIST, defined in the script is not visible after su gets executed.
How can we provide password automatically during each loop execution. Any idea?