Removing Garbage output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing Garbage output
# 1  
Old 07-04-2007
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
# 2  
Old 07-04-2007
Please provide us more info about your request.

Lorcan
# 3  
Old 07-04-2007
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 Smilie

Quote:
Originally Posted by lorcan
Please provide us more info about your request.

Lorcan
# 4  
Old 07-04-2007
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.

Code:
#!/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

Code:
+ 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

# 5  
Old 07-04-2007
All the unwanted displays come from the executeSQLToFile command.



You don't need to play with redirections, you can do :
Code:
#!/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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing characters and some output

Hi guys, So I am using an awk command to return a specific column in a file. I also need to remove some extra characters. What I have is :: (http-/0.0.0.0:8091-9)|23:00:41 And what I want is : http-/0.0.0.0:8091-9 I tried using the td command but it is only removing the ( ,... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

2. Shell Programming and Scripting

Help removing output from .sh script

I have the following script #!/bin/ksh # ********************************************************************** # # System: xxxx # # Filename: List_Largest_Files.sh # # Purpose: List 10 largest files in current partition # # Modification History: # 1.0 ... (9 Replies)
Discussion started by: pure_jax
9 Replies

3. Shell Programming and Scripting

Ignore garbage output file

Hi All, below is my shell script #!/bin/sh set -x echo "test for multiple values" UIDPSWD=`cat /projects/feeds/twest/uidpswd` echo "oracle connection test" full=/projects/feeds/twest/test_file values=`cut -d'|' -f1 $full|sed -e "s/.*/'&'/" -e 's/$/,/g' -e '$s/,$//'` sqlplus $UIDPSWD... (2 Replies)
Discussion started by: krupasindhu18
2 Replies

4. Shell Programming and Scripting

getting garbage in the output file of shell script

Hi, I wrote one shell script and I am calling 1 sql script inside shell script. When I am running the shell script, I am getting actual data as well as garbage data in the output file. Why the garbage is there in the log file. Please help if anybody having any ides. Script: ------- ... (2 Replies)
Discussion started by: vsachan
2 Replies

5. Shell Programming and Scripting

getting garbage in the output file of shell script

Hi Everyone, The problem is that I am getting messages other than the script in the current log file. Ideally the script should contain only the messages that are redirected to the log file. How to remove these unwanted data from the log file. Please help if you have any idea how to remove the... (0 Replies)
Discussion started by: vsachan
0 Replies

6. UNIX for Dummies Questions & Answers

getting garbage values in "df-k" output in solaris

Hi, I am running a command "df -k" to check the HDD utilization i am getting some garbage values in output of the command. Output coming Filesystem kbytes used avail capacity Mounted on /dev/dsk/c1t0d0s7 113197651... (0 Replies)
Discussion started by: varunksharma87
0 Replies

7. Shell Programming and Scripting

Remove Garbage Output

Hello Friends, In a script i m using different temporary file and i remove them in the end. During script execution i have some garbage output which is not required. For example: Garbage Output ++ rm temp_out temp_a temp_b temp_c ++ rm Filter1 Filter2 Script : Even i am redirecting rm... (7 Replies)
Discussion started by: Danish Shakil
7 Replies

8. Shell Programming and Scripting

vi command -output garbage char in HP-UX

Hi all , I am new to HP-UX flavour of unix. i am issuing simple "vi" comand on the command prompt it is showing me some garbage character in command prompt itself ..unreadable format. I tried opening an existing file using the vi editor --and same thing ... (3 Replies)
Discussion started by: jambesh
3 Replies

9. Shell Programming and Scripting

Removing first line from output

my script gives 10 outputs continuously..In each output i have to remove the first line in the output.How to do that. for eg : below is my output 0.00 1.00 5.00 0.00 7.00 i have to remove the first line of this output ie;0.00 (3 Replies)
Discussion started by: Krrishv
3 Replies
Login or Register to Ask a Question