Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with carriage return 2

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

I'm facing a quite annoying problem. Maybe you got an idea how to solve it.

On a daily basis there's an automated SAP Job generating a file.txt under a certain directory of the AIX machine.

Let's say the file contents look like this:

Code:
Person 1;Address;Phone       ;
Person 2;Address;Phone       ;
Person 3;Address;Phone       ;

Performing a

Code:
cat file.txt

everything looks fine.

However the directory is accessible by Windows using a Samba share and if we open the file using notepad or something similar it looks something like this:

Code:
Person 1;Address;Phone       ;0Person 2;Address;Phone       ;0Person 3;Address;Phone       ;

Note: There's not really a "0" between every line. It's more like some kind of square symbol representing some sort of carriage return. Problem is I can't display the symbol here, so I chose the "0" instead.

Now the question is: Do you have any idea how to get the file being displayed correctly under Windows ?

Problem is that we're running automated procedures on both sides (AIX and Windows) and we're unable to simply open the file with another application (e.g. Wordpad). It is important to automatically format the file somehow so that it is going to be displayed correctly under notepad ...

Regards
Thomas
 
you can try
dos2unix
or
cat filename|sed 's/'`echo "\010\013"`'/'`echo "\013"`'/g' > filenew
or
cat ${filename} | tr -d '\r' > ${filename}.new
or
sed -e 's/^M//g' $input_file > $input_file.fmt
or
sed -e 's/[^ -~]//g' $input_file > $input_file.fmt
 
I tried the commands, but I'm afraid that didn't do it ...

Regards
Thomas
 
Problem is there's some VB stuff involved reading the file content and there seems to be now way to get rid of the faulty CR display there.

We need to change the file somehow, so that Windows displays it correctly no matter what application is being used to display the file contents ...

Best point of time would be on AIX level as soon as the files have been created.

Regards
Thomas
 
Why don't you have the SAP programmers write the file in DOS text mode?

Or else

[tt]sed "s/$/`echo \\\r\\\c`/" </path/to/unix/file >/path/to/windows/file[/tt]


HTH,

p5wizard
 
As P5 says try wordpad instead of notepad or even better textpad which can handle *nix files.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Hi folks,

finally we found a working command. Here it is:

perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt

Thanks for all your great support !

Regards
Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top