IBM Support

How to convert a UNIX  LF to a CR/LF? (SCI57956)

Question & Answer


Question

How to convert a UNIX  LF to a CR/LF? (SCI57956)

Cause

Answer

Connect:Direct alone does not do this.  Please use other utilities to accomplish this.  See examples below:


1) Use a freeware utility or create a simple script which uses cat and/or  sed to add the CR to the LF:  Example follows showing how to accomplish the same funtcions using a script which contains cat and sed:  
Write dos2unix and unix2dos as scripts, see examples below:
The equivalent scripts look like:
 ====== dos2unix ======
cat file | sed "s/^M\{1,\}$//" | sed "$ s/^Z//" > file.new
====== unix2dos ======
cat file | sed "s/$/^M/" | sed "$ s/$/^Z/" > file.new


2) On Windows or UNIX, gzip and gunzip has a -a switch that tells Windows gunzip to uncompress a file and change all LF's to CRLF.


3) If this is a PGP file, UNIX and Linux has several different utilities that change "UNIX" text files to "Windows" text files.  One of these utilities can be run by inserting into a exiisting or new C:Direct UNIX process, an extra runtask step ( or extending a current runtask and pipe "|" the output straight into the PGP command they're already running on the box). Probably the fastest is the stream editor, "sed".





Assuming Step01 is the mainframe to Linux transfer, then step02 could be something like



Step02 (if step01 <=4 then)</font></font></p>

runtask (sed command to convert LF to CRLF)



Step03 (if step02 = 0 then)



runtask (PGP-encrypt the new file as before)



Step04 (if step03 = 0 then)



continue processing as before. Send file on to next UNIX machine.



In this scenario the customer would not have change anything. This will add a very small resource impact to that Linux box.



Here are some sed examples to use under Linux. At the end, the output is piped straight into another text file. However, the output could also be piped straight into the current PGP runtask with the "|" symbol.



# command line under ksh



cat mainframe.txt | sed "s/$/`echo -e \\\r`/" > windows.txt



# command line under bash



cat mainframe.txt | sed 's/$'"/`echo \\\r`/" > windows.txt

[{"Product":{"code":"SSKTYY","label":"IBM Sterling Connect:Direct for UNIX"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Historical Number

PRI1788

Product Synonym

[<p><b>]Change[</b><p>];[<p>]Other utilities or scripts can be used such as UNIX2DOS and DOS2UNIX or gzip ;and gunzip using the -a option.[</p>];[<p><b>]Fact[</b><p>];[<p>]Connect:Direct UNIX;All Releases. [<br />] SCI57956[</p>];[<p><b>]Goal[</b><p>];[<p>]How to convert a UNIX LF to a CR/LF?[</p>]

Document Information

Modified date:
24 July 2020

UID

swg21544890