Problem with loop within loop

Hi,

I work on Ab-initio ETL tool which is based on Unix. I made a small script which has two loop's one with in another. All the functionality is working for the first line of outer loop but when it comes to other lines of outer loop it is throwing error as command not found. Below is the script:

#set -x
#Sets up Sandbox Variables
cd `dirname $0`
cd ..
. ab_project_setup.ksh $(pwd)

setup_rc=$?
if [[ ${setup_rc} != 0 ]];
then
echo "Could not set up Project. Exiting"
exit ${setup_rc}
else
echo "Project Setup succeeded."
fi

REPORT_EMAIL_ADDRESS=`cat ${AI_BIN}/version_diff_report_email_address.txt`
echo "REPORT_EMAIL_ADDRESS = $REPORT_EMAIL_ADDRESS"

AI_LOC=`echo "$PREFIX"_SERIAL`
eval cd \$$AI_LOC
rm -f *_latest_tag.ksh *_status_path.txt *_tag_details.txt *_tag_date.txt *_tag_details1.txt

while read line
do

IFS="|"
set $line

echo "New Project : $line"
EME_PATH=$1
SANDBOX_PATH=$2

echo "EME_PATH=$EME_PATH"
echo "SANDBOX_PATH=$SANDBOX_PATH"

air project files "$EME_PATH" -basedir "$SANDBOX_PATH" -all 1>out.txt 2>log.txt

cat out.txt | egrep -v "Ignore|removed|directory|ignore|New" > out1.txt

PROJECT=`echo "$EME_PATH" | cut -d '/' -f5`
echo "PROJECT=$PROJECT"

awk '{print $1","$2}' out1.txt > "$PROJECT"_status_path.txt

#echo "PFA text pad containing details of $PROJECT" | mutt -s "Tag details of $PROJECT" -a "$PROJECT"_status_path.txt -- $REPORT_EMAIL_ADDRESS

rm -f "$PROJECT"_details.txt

while read data
do

IFS=","
set $data
export STATUS=$1
export PATH=$2

echo "STATUS=$STATUS"
echo "PATH=$PATH"

SPECIFIC_PATH=$EME_PATH/$PATH
echo "SPECIFIC_PATH=$SPECIFIC_PATH"

echo "air object versions -descending $SPECIFIC_PATH | head -3 | grep -v $SPECIFIC_PATH | tail -1" >> "$PROJECT"_latest_tag.ksh

done<"$PROJECT"_status_path.txt


done<${AI_BIN}/projects_list.txt

O/P:

version2.ksh: line 67: cat: command not found
version2.ksh: line 67: egrep: command not found
version2.ksh: line 69: cut: command not found
PROJECT=
version2.ksh: line 72: awk: command not found
version2.ksh: line 77: rm: command not found

Can any one please help me out in this

PATH is a special variable containing a list of paths to look for commands in, by altering it you are preventing the shell from being able to find ordinary commands! Use another variable name.

Then how come for the first time it identified correct variable and did the functionality required.I tried changing the variable names and executing the script but same result:(.:frowning:

Show your complete new script, please.

You overwrite the PATH in the inner loop. After the first iteration of the outer loop the PATH does not contain the common locations that the shell needs to find any binaries.

Do yourself a favor and do not mess with the PATH. Certainly, it is not necessarily to change it in every iteration of the second loop. Most of the times, when the need arises, is to "add" to the PATH, but it is uncommon to completely overwrite it.
In those, cases, you use the following statement:

PATH=$PATH:/adding/new/path