SFTP RC = 0

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
fmcdaid2
Posts: 2
Joined: Thu Apr 29, 2021 4:56 am

SFTP RC = 0

Post by fmcdaid2 »

Hi All,
For the following 2 scenarios, SFTP gives a RC=00, which will cause problems for subsequent processing. Is there a way of getting a non-zero return code.
Scenario 1 - If a file is not specified on the MVS partition, the GET creates a file on the OMVS partition.
Example:
cozsftp> get tata
Fetching /uttih/tata to tata
ZosSettingsÝI¨: Transfer options: clientcp=IBM-1047,gdgnt,mode=text,servercp=ISO8859-1,trim
PosixFileÝI¨: Closing file /u/op2c/tata - 16340 bytes received, 16340 bytes written
cozsftp> quit
CoZBatchÝI¨: returning rc=exitcode=0

Scenario 2 - If a file is not created on the MVS partition, the GET creates a file with a U format on MVS side:
Example:
cozsftp> get tata // MY.FILE.GET2
Fetching /uttih/tata to // MY.FILE.GET2
ZosSettingsÝI¨: Transfer options: clientcp=IBM-1047,gdgnt,mode=text,servercp=ISO8859-1,trim
ZosDatasetÝI¨: Opening dataset MY.FILE.GET2 for write with options: new catalog
IGD01010I GROUP STC USER OP2C DSN MY.FILE.GET2 TYPE PERM
ZosDatasetÝI¨: Closing dataset // MY.FILE.GET2 - 16340 bytes received, 172 records written
cozsftp> quit
CoZBatchÝI¨: returning rc=exitcode=0
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Re: SFTP RC = 0

Post by dovetail »

Scenario 1:

Since you did not specify a target file name, the sftp "get" command will create the same file name in the current local working directory.
So, this is working as expected.
See: https://dovetail.com/docs/sftp/cozsftp_ref.html

Scenario 2:

There seems to be an extra space between // and MY.FILE.GET2. I assume that you put that in there while scrubbing the actual data set name.

I think that your question is: if the target file is a non-existent data set ( //MY.FILE.GET2 ), it is created with RECFM=U.
RECFM is the default, unless your DFSMS rules change it.
If you want something different, then you would need to set an option, like:

cozsftp> lzopts recfm=fb,lrecl=80,space=cyl.3.1
cozsftp> lzopts mode=text
cozsftp> get tata //MY.FILE.GET2


see: https://dovetail.com/docs/sftp/options.html
Post Reply