date in transmitted file name

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
sftp
Posts: 10
Joined: Thu Feb 09, 2012 6:51 pm

date in transmitted file name

Post by sftp »

Hi,

I am trying to transmit a file into a interface server. I require to add the date variable field in the transmitted file name. I executed the below scripts but the file landed in the server with out the date value in the embedded file name. Could you please suggest.

coz_bin="/opt/lpp/coz/bin"
ruser="XXX"
server="XXXXX.YYYYYYY.VVVVVV"
ssh_opts="-oConnectTimeout=60"
ssh_opts="$ssh_opts -oServerAliveInterval=60"
ssh_opts="$ssh_opts -oStrictHostKeyChecking=yes"
export _BPX_SHAREAS=YES
IDATE="`date +%D`" (this field is displaying as 06/05/12)
$coz_bin/cozsftp $ssh_opts -vv -b- $ruser@$server
lzopts -la
lzopts mode=text,servercp=ISO8859-1,loglevel=E,sysout
cd /example
ls -la
put //DD:UPLOAD TESTFILE${IDATE}
ls -la

File landed in the server as:
-rw------- 1 0 0 34011 Jun 5 10:12 TESTFILE${IDATE}

I am using the Co:Z SFTP version: 2.0.1 (5.0p1) 2012-01-14

Thanks
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: date in transmitted file name

Post by dovetail »

One problem that I see is that you are not using a z/OS Unix "here document" for supplying input subcommands to the cozsftp command.
Because of this, the input commands are read without variable substitution by the shell.

To correct this:

Code: Select all

...
$coz_bin/cozsftp $ssh_opts -vv -b- $ruser@$server <<EOB
lzopts -la 
lzopts mode=text,servercp=ISO8859-1,loglevel=E,sysout
cd /example 
ls -la 
put //DD:UPLOAD TESTFILE${IDATE} 
ls -la 
EOB
Post Reply