SFTP And MVS Text Files

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

SFTP And MVS Text Files

Post by mwdazzo »

We are using cozbatch on MVS to invoke SFTP. If we want to put an MVS text file in text mode to a unix or windows sftp server does cozbatch handle the EBCDIC to ASCII conversion?

If not I guess the text file would have to be zipped, then it's not a text file. Any other suggestions? Thanks Matt
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

If you use COZBATCH to invoke the CO:Z SFTP command (client), then Co:Z SFTP will handle the conversion of text datasets.

To control this, you need to set the Co:Z SFTP client options using the "lzopts" command. See: http://dovetail.com/docs/sftp/client.html#client_opts

For example, in your COZBATCH job you could have the following:

Code: Select all

$coz_bin/cozsftp  $ssh_opts -b- $remoteuser@$server <<EOB 
lzopts mode=text,servercp=$servercp 
put //DD:MYDD $remotefile 
EOB 
(refer to "RUNSFTP" sample JCL for a complete example, which shows how to set the variables).

If not specified, the servercp defaults to "ISO8859-1" for the Co:Z SFTP client, unless it detects that the server is a z/OS system running Co:Z sftp, in which case they exchange their default codepages.

There are other options that you can use to control how dataset records are converted to a stream of bytes on the remote file when you have "mode=text" enabled. These include "localcp", "trim", and "linerule". The defaults will give you what most people expect as normal text conversion of a z/OS dataset. If the target is a Windows box, you might want to set "linerule=crlf", since the default is just a newline(linefeed).
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Post by mwdazzo »

I found why text transfers were not working properly, in the mode= parm a user was putting TEXT instead of text. The capital form of TEXT was not causing ebcdic to ascii translation to be done. tks.
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

This was fixed in a recent release (1.8.0):
http://dovetail.com/docs/cozinstall/changes.html
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Post by mwdazzo »

Is there a way in the scripting or cozsftp_config to make the mode= parm lower case no matter what is onthe jcl? In our case we are using a variable for mode=$transfer then we have an overide for transfer in the jcl. tks
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

I'm not exactly clear on what you are doing, can you post an example?
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Post by mwdazzo »

We have the variable in the lzopts and do the over ride in the jcl. If a user puts the 'text' in capitols the ebcdic to ascii is not done and we do not get any msg that the 'TEXT' format was not accepted. tks


lzopts mode=$TRANSFER,servercp=$servercp

//SFTPQCK EXEC SFTPMDX,
// PUTORGET=PUT,
// PUTMVS='NULLFILE',
// GETMVS='NULLFILE',
// FN=,
// LRECL=242,
// RECFM=FB,
// PWDPDS='ST1MAT.CNTL(PW)',
// LIB2='ST1MAT.CNTL',
// SITE1=SFTPASS,
// FTPWTO='NULLFILE',
// TRANSFER='text'
//QUICKJOB.SYSINB DD DSN=ST1MAT.CNTL.SFTP(CMDS)
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

I understand.

As I said, this is due to a bug that was fixed, but here is a workaround until you install the fix:

I assume that you are passing the &TRANSFER JCL variable to COZBATCH into a like-named shell variable.

Add this to your shell script before invoking the cozsftp command ( case is sensitive):

TRANSFER=$(echo $TRANSFER | tr '[:upper:]' '[:lower:]')
Post Reply