Removing Garbage output

I am using following code to read myfile.ddl line by line. But the thing is it is printing lot of garbage which are the names of the files and directories in which myfile.ddl is present. Kindly refine the code so that only myfile.ddl contents are only read

LOGFILE="logfile.txt"
DDLFILE="myfile.ddl"
exec 3<&0
exec 0<$DDLFILE
while read line
do
SQL=$line
executeSQLToFile ${LOGFILE} -x ${SQL}
done
exec 0<&3

Please provide us more info about your request.

Lorcan

The looping part of the code is printing the names of the files which are present in the parent directory of myfile.txt un-necessarily :frowning:

I used the same script and i have removed the function and have just printed the SQL in the logfile. It is working as desired.

#!/bin/ksh

LOGFILE="logfile.txt"
DDLFILE="myfile.ddl"
exec 3<&0
exec 0<$DDLFILE
while read line
do
SQL=$line
echo ${SQL} >> $LOGFILE
done
exec 0<&3

In debug mode

+ LOGFILE=logfile.txt
+ DDLFILE=myfile.ddl
+ exec
+ 3<& 0
+ exec
+ 0< myfile.ddl
+ read line
+ SQL=test1
+ echo test1
+ 1>> logfile.txt
+ read line
+ SQL=test2
+ echo test2
+ 1>> logfile.txt
+ read line
+ SQL=test3
+ echo test3
+ 1>> logfile.txt
+ read line
+ exec
+ 0<& 3

All the unwanted displays come from the executeSQLToFile command.

You don't need to play with redirections, you can do :

#!/bin/ksh

LOGFILE="logfile.txt"
DDLFILE="myfile.ddl"

while read SQL
do
   echo ${SQL} >> $LOGFILE
done <$DDLFILE

All the un-wanted displays come from the executeSQLToFile command.