Newbie question: sftp from prod z/OS to a test z/OS

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
DClassic53
Posts: 39
Joined: Wed Feb 11, 2009 10:23 am

Newbie question: sftp from prod z/OS to a test z/OS

Post by DClassic53 »

I'm running the regular Ported Tools on prod and just loaded Co:Z SFTP on my test system. I'm trying to get a text file from my zFS dir on prod and write it to a seq MVS file on test. Specifying mode=text,clientcp=ISO8859-1 seems to get the data readable but not broken into the correct logical records in the MVS dataset correctly. Line breaks seem to be happening on lower case 'e' (i.e., x'65').
I need a little assistance please.
David
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Which system is the client and which is the server?

Please post the commands that you issue from the client and we can help you figure it out.
DClassic53
Posts: 39
Joined: Wed Feb 11, 2009 10:23 am

Post by DClassic53 »

Server is running IBM Ported Tools. My client job on the test systems is running cozsftp

// EXEC DTLSPAWN
//STDIN *
coz_bin="/usr/lpp/coz/bin"
# Customize these ...
remoteuser="xxxxxxx"
server="yyyyyyy>"
remotefile="sftp.text.file"
export SSH_ASKPASS=.ssh/mypasswd.sh
export DISPLAY=none
ssh_opts="-oBatchMode=no" # allows ssh to use SSH_ASKPASS program
$coz_bin/cozsftp $ssh_opts -b- $remoteuser@$server
lzopts mode=text,clientcp=ISO8859-1
lzopts -a
get sftp.text.file //DD:DOWNLOAD
quit
//DOWNLOAD DD ....
David
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Short answer:

Instead of what you did, do this:

lzopts mode=text,servercp=IBM-1047

Long answer:

First, I'll connect a cozsftp client to a non-coz sftp server (both on z/OS):

> cozsftp myid@zos.com
sftp>

Now, notice that the default opts are binary:

> lzopts
mode=binary

If you get a remote HFS/zFS file to a local dataset in binary, it will download it fine, but in binary mode there are no record boundaries, so each record will be filled to max size.

Let set the mode to text:

> lzopts mode=text

Now, display the current options:

> lzopts
clientcp=IBM-1047 mode=text servercp=ISO8859-1 trim

Notice: In text mode, the client defaults to thinking that the server's codepage is ISO8859-1 (Latin ASCII). This is a reasonable guess, but wrong if the server is z/OS. (If you are running the Co:Z sftp server, the two will exchange extension packets so that they know the others actual default codepage!)

Now, you did this:

> lzopts mode=text,clientcp=ISO8859-1

Now the client thinks that his local codepage is ASCII and that the server's is also ASCII. So, when you transfer data, it won't be converted. That is why your data, which is really EBCDIC (IBM-1047) looks mostly OK.

But the line breaks are wrong. This is because the default linerule is to break on CR/LF/NL combinations in the source/server codepage. But since the server's codepage defaults to ISO8859-1, you didn't find correct terminators.

So, either do just this:

> lzopts mode=text,servercp=IBM-1047

(Since the clientcp defaults to IBM-1047)

Or, if your server is Co:Z SFTP, you can just do this:

> lzopts mode=text

(Since the Co:Z sftp client and server know how to exchange their default codepages).


Another tip:
You can use an environment variable to override default options for either Co:Z sftp client or server:

export SFTP_ZOS_OPTIONS="mode=text,servercp=IBM-1047"
DClassic53
Posts: 39
Joined: Wed Feb 11, 2009 10:23 am

Post by DClassic53 »

Got it! :D Worked as expected.
David
Post Reply