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?
Transfer of empty file
Re: Transfer of empty file
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
//
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
//
Re: Transfer of empty file
Thank you for pointing this out. I totally forgot on this 
