Removing a MVS file from CozBatch.

Discussion of the COZBATCH utility for z/OS
Post Reply
chaky
Posts: 6
Joined: Mon Jul 11, 2016 5:24 pm

Removing a MVS file from CozBatch.

Post by chaky »

Hi,

Currently we are placing a mainframe file on remote server. We want to make sure that as soon as the file is sent out, it is deleted. Is it possible?

Code: Select all

cd remotedir
pwd
ls -l
put //HLQLF.MIDQLF.LOWQLF.XXXXXX                 report.txt
Is it possible to delete the HLQLF.MIDQLF.LOWQLF.XXXXXX right after the put command?

Thank You.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Removing a MVS file from CozBatch.

Post by dovetail »

OpenSSH sftp (on which co:z sftp is based) doesn't have a "lrm" subcommand.

Here are a couple of options:

1) have a following jobstep that deletes the dataset; make the step conditional on a zero CC from the Co:Z SFTP step
2) use the "!" subcommand in sftp to execute the tso shell command:

!tso delete "'HLQ.DSN'"

(unless a relative DSN, this requires a literal single quote enclosed in double quotes)
chaky
Posts: 6
Joined: Mon Jul 11, 2016 5:24 pm

Re: Removing a MVS file from CozBatch.

Post by chaky »

Unfortunately TSO DELETE didn't work as the way suggested in step 2.

and Step 1 I can't try, reason being is this. One of the SFTP failed with UNKNOWN reason. We can't determine what was the issue and Cozbatch didn't give RC 1 or 255. It completed with RC 0 with doing nothing. So I was thinking that whenever a successful connect happens and the file is sent, if I delete the file right away, I would be knowing that everything happened successfully.

Code: Select all

debug3: input_userauth_banner

Please login with user ID and password.Connection closed by UNKNOWN

.73.049. Connection closed
lzopts: FSUM7351 not found
lzopts: FSUM7351 not found
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Removing a MVS file from CozBatch.

Post by dovetail »

Not enough information to tell what is going on.
You will have to attach your complete JCL and input script in order for someone to look at.

These errors:

lzopts: FSUM7351 not found
lzopts: FSUM7351 not found

are probably because the SSH connection failed but you have your subcommands in general STDIN vs a "here" document stdin to the cozsftp command.
chaky
Posts: 6
Joined: Mon Jul 11, 2016 5:24 pm

Re: Removing a MVS file from CozBatch.

Post by chaky »

I am passing below to STDIN

Code: Select all

cozsftp -F /export/home/prod/.ssh/ssh_config -vvv user_name@prod-server
lzopts mode=text,loglevel=I
lzopts -a
cd serverdircet
cd folder
pwd
put //HLQLF.MIDQLF.LOWQLF.XXXXXX                 report.txt
ls -l
pwd
And below is the output in STDOUT. If we see that connection gets closed by UNKNOWN and Yes, I agree that "FSUM7351 not found" would have come when the connection failed.

Code: Select all

 CoZBatch.N.: Copyright (C) 2005-2009 Dovetailed Technologies LLC. All rights reserved.
 CoZBatch.N.: version 2.1.1 2012-03-16
 CoZBatch.I.: executing progname=login-shell="-/bin/sh"
 Co:Z SFTP version: 2.1.1 (5.0p1) 2012-03-16
 Copyright (C) Dovetailed Technologies, LLC. 2011. All rights reserved.
 Connecting to prod-server...
 .88.997. debug3: connect_to_server arg=/bin/ssh
 .88.997. debug3: connect_to_server arg=-oForwardX11 no
 .88.997. debug3: connect_to_server arg=-oForwardAgent no
 .88.997. debug3: connect_to_server arg=-oClearAllForwardings yes
 .88.997. debug3: connect_to_server arg=-F/export/home/prod/.ssh/ssh_config
 .88.997. debug3: connect_to_server arg=-v
 .88.997. debug3: connect_to_server arg=-v
 .88.997. debug3: connect_to_server arg=-v
 .88.997. debug3: connect_to_server arg=-luser_name
 .88.997. debug3: connect_to_server arg=-oProtocol 2
 .88.997. debug3: connect_to_server arg=-s
 .88.997. debug3: connect_to_server arg=prod-server
 .88.997. debug3: connect_to_server arg=sftp
 OpenSSH_5.0p1, OpenSSL 1.0.1c 10 May 2012
 debug1: Reading configuration data /export/home/prod/.ssh/ssh_config

 debug1: Reading configuration data /etc/ssh/zos_ssh_config

 debug3: RNG is ready, skipping seeding

 debug1: zsshSmfSetConnSmfStatus: changing SMF status from 0 to 83

 debug1: Rhosts Authentication disabled, originating port will not be trusted.

 debug2: ssh_connect: needpriv 0

 debug1: Connecting to prod-server .12.34.12.34. port 22.

 debug1: Connection established.

 debug1: cipher_init: none from source OpenSSL

 debug1: cipher_init: none from source OpenSSL

 debug3: zsshGetpw: passwd name=XXX123, uid=777777772, gid=1, dir=/export/home/XXX123, shell=/bin/sh

 debug3: Not a RSA1 key file /export/home/prod/.ssh/id_rsa.

 debug2: key_type_from_name: unknown key type '-----BEGIN'

 debug3: key_read: missing keytype

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug3: key_read: missing whitespace

 debug2: key_type_from_name: unknown key type '-----END'

 debug3: key_read: missing keytype

 debug1: identity file /export/home/prod/.ssh/id_rsa type 1

 debug1: Remote protocol version 2.0, remote software version GXSSSHD_Comments

 debug1: no match: GXSSSHD_Comments

 debug1: Enabling compatibility mode for protocol 2.0

 debug1: Local version string SSH-2.0-OpenSSH_5.0

 debug2: fd 3 setting O_NONBLOCK

 debug3: RNG is ready, skipping seeding

 debug1: SSH2_MSG_KEXINIT sent

 debug1: SSH2_MSG_KEXINIT received

 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1
 4-sha1,diffie-hellman-group1-sha1

 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss

 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast1
 28-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast1
 28-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96
 ,hmac-md5-96

 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96
 ,hmac-md5-96

 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib

 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib

 debug2: kex_parse_kexinit:

 debug2: kex_parse_kexinit:

 debug2: kex_parse_kexinit: first_kex_follows 0

 debug2: kex_parse_kexinit: reserved 0

 debug2: kex_parse_kexinit: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,dif
 fie-hellman-group-exchange-sha256

 debug2: kex_parse_kexinit: ssh-dss,ssh-rsa

 debug2: kex_parse_kexinit: aes128-cbc,3des-ctr,aes128-ctr,3des-cbc,blowfish-cbc,arcfour,arcfour128

 debug2: kex_parse_kexinit: aes128-cbc,3des-ctr,aes128-ctr,3des-cbc,blowfish-cbc,arcfour,arcfour128

 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha256@ssh.com

 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha256@ssh.com

 debug2: kex_parse_kexinit: none,zlib

 debug2: kex_parse_kexinit: none,zlib

 debug2: kex_parse_kexinit:

 debug2: kex_parse_kexinit:

 debug2: kex_parse_kexinit: first_kex_follows 0

 debug2: kex_parse_kexinit: reserved 0

 debug1: mac_setup_by_id: hmac-md5 from source OpenSSL

 debug2: mac_setup: found hmac-md5

 debug1: kex: server->client aes128-ctr hmac-md5 none

 debug1: mac_setup_by_id: hmac-md5 from source OpenSSL

 debug2: mac_setup: found hmac-md5

 debug1: kex: client->server aes128-ctr hmac-md5 none

 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent

 debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP

 debug2: dh_gen_key: priv key bits set: 131/256

 debug2: bits set: 507/1024

 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent

 debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY

 debug3: Received SSH2_MSG_IGNORE

 debug3: put_host_port: .12.34.12.34.:22

 debug3: put_host_port: .prod-server.:22

 debug3: check_host_in_hostfile: filename /export/home/prod/.ssh/known_hosts

 debug3: check_host_in_hostfile: match line 1

 debug3: check_host_in_hostfile: filename /export/home/prod/.ssh/known_hosts

 debug3: check_host_in_hostfile: match line 2

 debug1: Host '.prod-server.:22' is known and matches the RSA host key.

 debug1: Found key in /export/home/prod/.ssh/known_hosts:1

 debug2: bits set: 481/1024

 debug1: ssh_rsa_verify: signature correct

 debug2: kex_derive_keys

 debug2: set_newkeys: mode 1

 debug1: cipher_init: aes128-ctr from source OpenSSL

 debug1: SSH2_MSG_NEWKEYS sent

 debug1: expecting SSH2_MSG_NEWKEYS

 debug2: set_newkeys: mode 0

 debug1: cipher_init: aes128-ctr from source OpenSSL

 debug1: SSH2_MSG_NEWKEYS received

 debug1: SSH2_MSG_SERVICE_REQUEST sent

 debug2: service_accept: ssh-userauth

 debug1: SSH2_MSG_SERVICE_ACCEPT received

 debug2: key: /export/home/prod/.ssh/id_rsa (179A96F8)

 debug3: input_userauth_banner

 Please login with user ID and password.Connection closed by UNKNOWN

 .73.049. Connection closed
 lzopts: FSUM7351 not found
 lzopts: FSUM7351 not found
 cd: serverdircet: EDC5129I No such file or directory.
 cd: folder: EDC5129I No such file or directory.
 put: FSUM7351 not found
 CoZBatch.I.: returning rc=exitcode=0
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Removing a MVS file from CozBatch.

Post by dovetail »

You need to use a << "here document" to properly input the subcommands into cozsftp command.

See the sample JCL:

SFTPSAMP (preferred)
RUNSFTP (old version)
chaky
Posts: 6
Joined: Mon Jul 11, 2016 5:24 pm

Re: Removing a MVS file from CozBatch.

Post by chaky »

I am sorry, I may be asking a very dumb question. But where I can see these sample JCLs you are taking about?

See the sample JCL:

SFTPSAMP (preferred)
RUNSFTP (old version)
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Removing a MVS file from CozBatch.

Post by dovetail »

The Co:Z SAMPJCL dataset is part of the installation.

See: https://dovetail.com/docs/cozinstall/install.html
Post Reply