^M character in the log file

Hi ..

when i am running the following simple script, i am getting the log file as ""test1.log?"", there is a ^M charater. I dont know why it is generating like that.

when i tried to replace the ^M character, it is saying there is no pattern like that.
:%/ctrlV ctrlM//g (pattern not found).

Can anyone suggest me how can i get rid of that charater?

TEST_VAR='HELLO WORLD'
PROC='testproc'
sqlplus apps/sup3rm5n@fmsdev3 << EOF > test1.log
set serveroutput on size 200000
whenever sqlerror continue
set echo on
exec dbms_output.put_line('$TEST_VAR');
exit;
EOF

[/FONT][/SIZE]
[/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]

Apparently sqlplus is giving you DOS style line breaks, and the ^M is a carriage return character, octal 15 or hex 0x0D. If you cannot convince sqlplus to use just linefeed, you can remove it by piping through tr:

sqlplus . . .  <<EOF | tr -d '\15' > test1.log

Hi DGpickett..

Thanks for the reply..
Its not about the content of the file..but the file name isgetting created like ""test1.log?""

Thanks

Please copy/paste (using code tags) the output of cat -vet yourScriptFile .
Are you by any chance editing the script file under Windows and transferring the file to UNIX with ftp?

Yes, the > shell has no tendency to add ^M to a file name.

output of cat -vet yourScriptFile

echo ' '^M$
echo 'ODS to Stage Synch job started ' ^M$
date^M$
echo ' '^M$
#|---------------------------------------------------------------------^M$
#| Step 1: Execute the procedure.^M$
#|---------------------------------------------------------------------^M$
PROC='OS2STG_JOB'^M$
PKG='SYNCH_JOBS'^M$
TEST_VAR='HELLO WORLD'^M$
sqlplus username/password2dbid << EOF > $LOG_DIR/$PROC.sql.log^M$
set serveroutput on size 200000^M$
whenever sqlerror continue^M$
set echo on^M$
exec dbms_output.put_line('$TEST_VAR');^M$
exit;^M$
EOF^M$

[/SIZE][/FONT][/SIZE][/FONT]

---------- Post updated at 03:43 PM ---------- Previous update was at 03:39 PM ----------

when i try to remove those character with the following command..

:%/ctrlV ctrlM//g (pattern not found).

it is showing pattern not found

---------- Post updated at 03:45 PM ---------- Previous update was at 03:43 PM ----------

"""Are you by any chance editing the script file under Windows and transferring the file to UNIX with ftp?"""

Yes.. i am using ""reflection"" for transferring files.. (but the transfer mode is in "ASCII")

The dos2unix (also: dos2ux) command is designed to get rid of the windows carriage returns in a file. ^M is part of windows/dos carriage control.

Well, vi can remove them, too, very much like that, but each editor has different escapes. Some escapes of enter are carriage return, some are line feed! try ':%/.$//'

... or as previously suggested:

tr -d '\15' < myScriptFile >mySaneScriptFile && mv mySaneScriptFile  myScriptFile 

Hi all..

Thanks a ton..

i used dos2unix command to convert my file..after that my script is working perfectly fine...

Thanks a lot for your help..

---------- Post updated at 04:40 PM ---------- Previous update was at 04:39 PM ----------

Hi DG..

I tried you command ':%/.$//'. it is not working ..

(invalid editor command)