The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
vi command -output garbage char in HP-UX jambesh Shell Programming and Scripting 3 08-30-2007 06:07 AM
Removing Null data in output liketheshell Shell Programming and Scripting 2 08-13-2007 04:59 PM
Removing first line from output Krrishv Shell Programming and Scripting 3 01-09-2007 06:20 AM
Script to Remove Garbage Character Eddie_The_Head Shell Programming and Scripting 4 03-28-2006 05:09 AM
Garbage characters in display Haleja001 UNIX for Dummies Questions & Answers 0 09-21-2005 09:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
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 (permalink)  
Old 07-04-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
Please provide us more info about your request.

Lorcan
  #3 (permalink)  
Old 07-04-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
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

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

Lorcan
  #4 (permalink)  
Old 07-04-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
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 (permalink)  
Old 07-04-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,416
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0