|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 ) |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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:
Thanks, Gio |
|
#5
|
|||
|
|||
|
Try:
man dos2unix or on some boxes man dos2ux |
|
#6
|
|||
|
|||
|
Quote:
That was it Jim. Thanks for your help. Gio |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
hi jim
please say me: how did you see that ^M ? and of course the u2d|d2u ... ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > sed NOT redirecting output |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|