Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Unix shell script drops chars sent to sqlplus - here document, etc.
>>>>> "Bricklen" == Bricklen <BAnderson_at_PresiNET_abc.com> writes:
Bricklen> I believe it is because of the conversion from dos/windows Bricklen> crlf to unix crlf (or the lack of conversion).
Bricklen> I use ultraedit and there is a converter that converts from Bricklen> dos->unix and back, etc. (I've encountered the problem Bricklen> several times where I had the same error msg).
Bricklen> Try formatting it in emacs/vi if you don't have ultraedit Bricklen> or something comparable.
Bricklen> hth
Here are some perl scripts which will do the conversions. They could be a lot smaller, but are probably a bit clearer this way.
# Convert from dos 2 unix.
# replace ^M with ^J
local($infile,$outfile);
if ($#ARGV != 1) {
print "Usage: $0 [infile] [outfile] \n";
exit;
}
($infile = $ARGV[0]) if (defined $ARGV[0]); ($outfile = $ARGV[1]) if (defined $ARGV[1]);
open(INFILE, "<$infile") || die "Can't open input file $infile"; open(OUTFILE, ">$outfile") || die "Can't open input file $outfile";
while ($data=<INFILE>) {
$data =~ s/\r//;
print OUTFILE $data;
}
close(INFILE);
close(OUTFILE);
--------------------- dos2unix end------------------------------------- --------------------- cut here - unix2dos -----------------------#!/usr/bin/perl
# Convert from unix 2 dos.
# add ^M after the ^J
local($infile,$outfile);
if ($#ARGV != 1) {
print "Usage: $0 [infile] [outfile] \n";
exit;
}
($infile = $ARGV[0]) if (defined $ARGV[0]); ($outfile = $ARGV[1]) if (defined $ARGV[1]);
open(INFILE, "<$infile") || die "Can't open input file $infile"; open(OUTFILE, ">$outfile") || die "Can't open input file $outfile";
while ($data=<INFILE>) {
$data =~ s/\n/\r\n/;
print OUTFILE $data;
}
close(INFILE);
close(OUTFILE);
-- Tim Cross The e-mail address on this message is FALSE (obviously!). My real e-mail is to a company in Australia called rapttech and my login is tcross - if you really need to send mail, you should be able to work it out!Received on Tue Mar 04 2003 - 02:07:50 CST