Convert ASCII LF to EBCDIC LF

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
vasanthz
Posts: 10
Joined: Thu Aug 03, 2017 4:34 pm

Convert ASCII LF to EBCDIC LF

Post by vasanthz »

Hi,

I have a input text file on Windows with only the below line

Code: Select all

A.B
When viewed in a hex editor the file has the below hex equivalents

Code: Select all

x'41'x'0a'x'42'
I FTP'ed the file

Code: Select all

C:\Users\wells>ftp MFSERV
Connected to MFSERV.company.com.
220-FTPD1 IBM FTP CS V1R13 at MFSERV.company.us, 16:56:53 on 2017-08-16.
220 Connection will close if idle for more than 5 minutes.
User (MFSERV.company.com:(none)): WELLS
331 Send password please.
Password:
230 WELLS is logged on.  Working directory is "WELLS.".
ftp> ascii
200 Representation type is Ascii NonPrint
ftp> put C:\ftp\sample.file 'WELLS.file.ftp'
200 Port request OK.
125 Storing data set WELLS.FILE.FTP
250 Transfer completed successfully.
ftp: 3 bytes sent in 0.00Seconds 3000.00Kbytes/sec.
ftp>
The FTP file looks like below. The x'0a' (LF) from input file is converted to its equivalent EBCDIC value x'25' (LF)

Code: Select all

Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 A B                                                                     
       C2C444444444444444444444444444444444444444444444444444444444444444444444
       152000000000000000000000000000000000000000000000000000000000000000000000
I SFTP'ed the file

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Users\wells>psftp MFSERV
login as: wells
wells@MFSERV's password:
Remote working directory is //WELLS
psftp> ls /+mode=text,linerule=crlf
Listing directory /+mode=text,linerule=crlf
 linerule=crlf
 mode=text
psftp> put C:\ftp\sample.file //WELLS.FILE.SFTP
local:C:\ftp\sample.file => remote://WELLS.FILE.SFTP
psftp>
The SFTP file looks like below, The x'0a' (LF) from input file is converted into x'15' (NL).

Code: Select all

Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 A B                                                                     
       C1C444444444444444444444444444444444444444444444444444444444444444444444
       152000000000000000000000000000000000000000000000000000000000000000000000
Could you please let me know the SFTP options to convert LF in Windows to LF in Ebcdic?
FTP converts it correctly, I am not aware of the SFTP options to do it.

This is sort of related to http://community.dovetail.com/forum/vie ... f=8&t=1689
Once we have the solution for this thread, I guess I would be able to apply the technique for the other thread

Thanks in advance,
Vasanth.S
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Convert ASCII LF to EBCDIC LF

Post by dovetail »

You have specified:

linerule=crlf

so, a LF only will not work.

If you don't set this setting, the default is "flexible" which will work.

For more information, see the documentation here:
vasanthz
Posts: 10
Joined: Thu Aug 03, 2017 4:34 pm

Re: Convert ASCII LF to EBCDIC LF

Post by vasanthz »

Thank you for the swift response & your suggestion. With linerule=flexible the data is split into two records, we want the data to be only a single record similar to the FTP file.

File with linerule=flexible

Code: Select all

Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 A                                                                       
       C44444444444444444444444444444444444444444444444444444444444444444444444
       100000000000000000000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------ 
000002 B                                                                       
       C44444444444444444444444444444444444444444444444444444444444444444444444
       200000000000000000000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------ 

desired output:

Code: Select all

Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 A B                                                                     
       C2C444444444444444444444444444444444444444444444444444444444444444444444
       152000000000000000000000000000000000000000000000000000000000000000000000
Regards,
Vasanth.S
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Convert ASCII LF to EBCDIC LF

Post by dovetail »

I'm sorry, I didn't read your problem carefully.

The default translate tables are IBM-1047 <-> ISO8859-1 for CO:Z SFP.
The default IBM FTP translate table is different in a couple of ways.

Co:Z SFTP also supports FTP-style translate tables. If you want to use the same translate table as FTP, you can do this:

ls /+linerule=crlf,trtab=STANDARD
vasanthz
Posts: 10
Joined: Thu Aug 03, 2017 4:34 pm

Re: Convert ASCII LF to EBCDIC LF

Post by vasanthz »

Thank you. Your solution Works Great!

Code: Select all

Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 A B                                                                     
       C2C444444444444444444444444444444444444444444444444444444444444444444444
       152000000000000000000000000000000000000000000000000000000000000000000000
We want to mimic SFTP similar to FTP at our shop, so that the application programmers have less effort in changing their code.
I am planning to make this as the default at our shop.

Also I am not good at explaining how cr lf nl works to application programmers, so customizing SFTP to work like FTP is an easier solution.

Thanks again,
Vasanth.S
Post Reply