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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to read a file

Status
Not open for further replies.

gah

Programmer
Apr 12, 2002
8
US
I am on a IBM AIX RS6000 UNIX SYSTEM trying to create a mass compile script.

I am trying to read a file called COBLIST with the following data in it:
abc.pco
123.pco
xyz.pco

I want to read each of these records.

Here is the script that I have but am having problems finding out what's wrong with it.

while true
do
read COBLIST
COBFILE=`echo $COBLIST | cut -d. -f1`
COBERR=$COBFILE".err"

echo "STEP 2-PreCompile PRO*Cobol program "
make -f /usr/local/bin/procob.mk build COBS=$COBFILE.cob EXE=$COBFILE 2>$COBERR


if [ -s "$COBERR" ]
then
echo "/n/nCompiled with Errors/n/n"
else
rm $COBERR
fi


if [ -z "$COBLIST" ]
then
break
fi

#echo $COBFILE>coblist


done
#END OF SCRIPT

Any help is greatly appreciated!

Thanks Greg
 
read is followed by a variable but not a file name.

So 'read COBLIST' means it read something and assign it to a variable COBLIST.

Change your code like these:
while read line
do
COBFILE=`echo $line | cut -d. -f1`
COBERR=$COBFILE".err"
.
skipped
.
done < COBLIST

tikual
 
To read from file....

while read COBLIST
do
:
done < coblist
 
Thanks I do appreciate the info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top