UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 7th, 2004, 07:42 PM
jaramill jaramill is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 jaramill User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 24 sec
Reputation Power: 0
sed NOT redirecting output

Background info

$ uname -a
SunOS harley 5.8 Generic_108528-22 sun4u sparc SUNW,Ultra-Enterprise

$ echo $SHELL
/bin/ksh

Here's my shell script.

input=$1
sed -e "s/COL3_VALUE/${input}/" mytest2.ctl > mytest.ctl
sqlldr PARFILE=mytest.par

The script fails when trying to execute the Oracle SQL* Loader command. The error is that in the PARameter file

userid=scott/tiger
control=mytest.ctl
data=mytest.dat

It doesn't find the ConTroL file "mytest.ctl", yet I have the output from sed being redirected to that CTL file. I've even tried the redirect & append to an existing file ">>" and still nothing.

Any clues?

Thanks,
Gio

Reply With Quote
  #2  
Old July 7th, 2004, 08:19 PM
jaramill jaramill is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 jaramill User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 24 sec
Reputation Power: 0
Here's the CTL file

LOAD DATA
TRUNCATE
INTO TABLE mytest
FIELDS TERMINATED BY '|' TRAILING NULLCOLS
(
COL1 INTEGER EXTERNAL,
COL2 INTEGER EXTERNAL,
COL3 CONSTANT COL3_VALUE
)

Reply With Quote
  #3  
Old July 8th, 2004, 09:29 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 20 m 49 sec
Reputation Power: 48
It doesn't know the path to the file

Code:
sed -e "s/COL3_VALUE/${input}/" mytest2.ctl > /full/path/mytest.ctl
sqlldr PARFILE=mytest.par


in mytest.par
Code:
..... /full/path/mytest.ctl

Reply With Quote
  #4  
Old July 8th, 2004, 01:36 PM
jaramill jaramill is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 jaramill User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 24 sec
Reputation Power: 0
Actually it turns out that since I was using Notepad, I had to put in a semicolon at the end of each Unix command with no carriage returns, thus the script now works. No need to specify the full path since it's implied that the file name is in the same directory in which I'm running the script or sql loader script.

Here's the contents of my script as is, with no carriage returns/line feeds:
Quote:
rm mytest.ctl;rm mytest.log;sed -e "s/COL3_VALUE/${1}/g" mytest_orig.ctl > mytest.ctl;sqlldr PARFILE=mytest.par

Thanks,
Gio

Reply With Quote
  #5  
Old July 8th, 2004, 02:41 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 20 m 49 sec
Reputation Power: 48
Try:

man dos2unix

or on some boxes

man dos2ux

Reply With Quote
  #6  
Old July 8th, 2004, 02:54 PM
jaramill jaramill is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 9 jaramill User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 24 sec
Reputation Power: 0
Quote:
Originally Posted by jim mcnamara
Try:
man dos2unix


That was it Jim. Thanks for your help.

Gio

Reply With Quote
  #7  
Old September 9th, 2004, 11:40 AM
andyb1ack andyb1ack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 60 andyb1ack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 14 sec
Reputation Power: 5
Hi Gio, Jim,

Sometimes when you copy and paste from Windows to UNIX, or ftp even, there are some odd characters in the UNIX text file. You can see them by doing "cat -vet file_name"

They will show up with a ^ at the front indicating that they are control characters.

The most common one is to have a ^M (ctrl+m) at the end of each line.

You can remove these using sed command "s/^M//"

Note that you have to add a ctrl+m not a "^" followed by an "m" , and you do this by holding down ctrl and then typing v then m.

Cheers,
Andy

Reply With Quote
  #8  
Old September 9th, 2004, 12:25 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,098 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 8 h 44 m 33 sec
Reputation Power: 9
hi jim
please say me: how did you see that ^M ?
and of course the u2d|d2u ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > sed NOT redirecting output


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT