dos to unix on Linux environment

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

sonia jacob
Participant
Posts: 122
Joined: Mon Jul 05, 2004 1:33 pm
Location: MA

dos to unix on Linux environment

Post by sonia jacob »

Hi All,

I use dos2unix to convert source files on the windows machine to unix file on a SunSolaris machine. After which I can process the file without the option "Record Delimitor String = Dos format". on the sequential file stage

But dos2unix does not seem to work on a Linux box.

Has anyone tried dos2unis on linux?, faced similar issue?
Regards
Sonia Jacob
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

dos2unix and unix2dos are present on some platforms. Try doing man dos2unix or man unix2dos, if there is help present, then it is most probably supported. Only your id doesnt have access to it. You need to contact your system admin for that.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Don't know if it exists on Linux or not. But even if it does, it may be in a directory not mentioned in your PATH environment variable (which specifies the directories to be searched when looking for a command).

What error message is generated?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sonia jacob
Participant
Posts: 122
Joined: Mon Jul 05, 2004 1:33 pm
Location: MA

command and error

Post by sonia jacob »

ray.wurlod wrote:Don't know if it exists on Linux or not. But even if it does, it may be in a directory not mentioned in your PATH environment variable (which specifies the directories to be searched when looking for ...
Command : dos2unix file.csv file2.csv

Error:
dos2unix: converting file file.csv to UNIX format ...
dos2unix: problems converting file file.csv
Regards
Sonia Jacob
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Like previously asked by DSGuru2B, do you have permission to write in the directory where your output file exists. Just want to make sure that this is not a permissions issue.

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Try

Code: Select all

dos2unix file1 > file2
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

OK, that error message tells you that dos2unix does exist on your server machine, since it was the dos2unix command itself that generated the error message.

It's also telling you that there's something about file.csv that it did not like - could not convert. You will need to scrutinize file.csv with an intense scrute (or a hex editor) to work out what this is - maybe the FTP utility automatically converted the line terminators.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

ftp does convert it from dos to unix and back. I think we needed to ask this question first, why do you need to use that command in the first place???
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

FTP can convert it, I wouldn't say 'does'. Way too many packages seem to default to a binary transfer which means you end up with a DOS file on your UNIX system.

However, if you know that's what you are going to get why not just read it as a DOS file? Curious what's so horrible about using the DOS record delimiter setting? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Well, I have always created test files on my desktop and ftp'd them over to the unix environment. Just a simple put command. It would convert it. No special command to convert it along with ftp. That is due to the fact that command line ftp uses ascii transfer mode as a default mode. The recieving machine saves those transfered bytes in the appropriate format, i.e, unix saves it in unix format, machintosh saves it in Mac format and so on.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No-one except gomers like us would use command line ftp from a Windows box. :wink:

Here, any business type folk who provide Excel csv files (typically) via ftp all use some sort of GUI package... and for that same reason we practically always get DOS files as a result. Go figure.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Well, i guess then the OP needs to either convert the format explicity like he/she has been trying or as Craig said, use Dos record end setting. Check out thislink for a few more ways of doing that.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sonia jacob
Participant
Posts: 122
Joined: Mon Jul 05, 2004 1:33 pm
Location: MA

Post by sonia jacob »

chulett wrote:No-one except gomers like us would use command line ftp from a Windows box. :wink:

Here, any business type folk who provide Excel csv files (typically) via ftp all use some sort of GUI package... and for that same reason we practically always get DOS files as a result. Go figure.
DSguru2B wrote:Well, I have always created test files on my desktop and ftp'd them over to the unix environment. Just a simple put command. It would convert it. No special command to convert it along with ftp. That is due to the fact that command line ftp uses ascii transfer mode as a default mode. The recieving machine saves those transfered bytes in the appropriate format, i.e, unix saves it in unix format, machintosh saves it in Mac format and so on.
We have all our sources files put on a Windows machine which is mounted on a Unix box (its like having mapped drive)

ETL connects to the windows directory using a sequential stage and reads the file with a records delimitor = DOS format. And we were good

Now the source files (.csv) started to have blank lines in them which sequential stage does not like. Hence we called a shell script that would convert the file to unix move to the unix etl server and remove the blank lines.

Before have a shell script to remove blank lines I did try to use reject link hoping that the sequential stage would just reject the record which is not per the format (blank lines). But it throws a warning which is a issue to us.
Regards
Sonia Jacob
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

tr worked for me.

tr -d '\r' < FILENM > FILENM.dos2unix

thanks to all.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And who would you be?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply