Page 1 of 1

Unix- Dos Style Issue

Posted: Mon May 21, 2007 12:43 am
by Amit_111
Hi all,

I am facing an issue with the line termination. I have some Jobs which I first tested them on windows environment where I used the line termination as "DOS style". Here all Jobs executed successfully.
But when I executed the same jobs on UNIX DS server it gave me warning saying "read_fixedwidth() - row 1, too many columns in record". Here when I changed it to UNIX style, it worked and the Job finished without warnings.
Now what is happening is that on UNIX DS Server, some of my jobs are executing successfully with Line termination as UNIX style and some are getiing executed with Line termination as DOS Style.
I do not want this to happen. I want all the source files(used in diffeent jobs) to use the same kind of Line termination and get successfully executed because the O/P files generated by these jobs are used by a common job and I cannot keep changing the Line Termination according to the different source files used in that common job.
I went through the search but couldnt find the solution.
Please can anyone explain as to why is this happening? and what should be done to successfully handle this issue?

Thanks in Advance.

Posted: Mon May 21, 2007 12:59 am
by WoMaWil
DOS-Line-Termination is CR and LF (CR=Cursor Return CHAR(13), LF=Line Feed CHAR(10).
UNIX-Line-Termination is only LF

Important is to write and read with the same kind of termination. If you mix them up you get an error. (to much colums).

You can use both kinds of termination in both worlds without problems (if staying in DataStage) but you should use the adequate termination in each world for to use the other local tools to read and write without problems.

Posted: Mon May 21, 2007 6:43 am
by Amit_111
How to find out whether a particular source file should be given a DOS Style or a UNIX style??
We asked our client but he is also not aware of what kind of Line termination is used.

Posted: Mon May 21, 2007 7:30 am
by DSguru2B
Change all the files to OS your sitting on. If it is UNIX then make sure all the files are UNIX format. You can find a bunch of commands to do this. tr, dos2unix, sed etc to name a few. You can search for exact syntax on google.

Posted: Mon May 21, 2007 7:49 am
by rafik2k
CR is carriage return or Cursor Return :(


WoMaWil wrote:DOS-Line-Termination is CR and LF (CR=Cursor Return CHAR(13), LF=Line Feed CHAR(10).
UNIX-Line-Termination is only LF

Important is to write and read with the same kind of termination. If you mix them up you get an error. (to much colums).

You can use both kinds of termination in both worlds without problems (if staying in DataStage) but you should use the adequate termination in each world for to use the other local tools to read and write without problems.

Posted: Mon May 21, 2007 7:50 am
by DSguru2B
Half glass empty, half glass full. :wink:

Posted: Mon May 21, 2007 7:54 am
by chulett
Just use the type that is appropriate for the file. I don't seen the need to convert everything one way or the other, per se. And it's easy to check.

Open the file in vi. Look at the end of each record. Does it have a "^M" at the end? Yes = DOS file, no = UNIX file. Easy Peasy. :wink:

Posted: Mon May 21, 2007 2:36 pm
by ray.wurlod
Use dos2unix from a before-stage or before-job subroutine (ExecSH). If the file was DOS-style it's now UNIX-style. If it was already UNIX-style, it remains so.

Posted: Tue May 22, 2007 7:49 am
by Amit_111
Thanks Guys the command dos2unix worked :D