Transfer of empty file

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
sven
Posts: 6
Joined: Mon Feb 28, 2011 1:44 pm

Transfer of empty file

Post by sven »

We have a SFTP transfer that always replaces the same file (with put command) and our clients would like to make an exception in a way that, when file that is to be transferred is empty no replacement occurs. In other words that whole JCL JOB works only when there is some content in file that we "put".

Is there some property that I could use to make this possible? Or someone have some other idea how to achieve this?
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Re: Transfer of empty file

Post by dovetail »

When you run COZBATCH, you are running a z/OS Unix shell script.
You can add some tests like this:

//STDIN DD *

# Read the dataset. Pipe into head so that we only read the beginning.
# Pipe the output into wc to get a count of how many read
# Note: this won't work with a //DD:NAME, since $(..) will force into a separate address space
count=$(fromdsn //HLQ.MY.DSN 2>/dev/null | head | wc -c)
if test $count -gt 0
then
# run cozsftp to transfer the file
....
else
echo "The dataset was empty or could not be opened"
fi
//
sven
Posts: 6
Joined: Mon Feb 28, 2011 1:44 pm

Re: Transfer of empty file

Post by sven »

Thank you for pointing this out. I totally forgot on this :roll:
Post Reply