Get remoteuser and password from PDS member pass to variable

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
Randy
Posts: 16
Joined: Thu Jul 08, 2010 1:36 pm

Get remoteuser and password from PDS member pass to variable

Post by Randy »

We are running COZPATCH to PUT multiple z/OS datasets to various UNIX servers. The PUT command is working thus:

Code: Select all

$coz_bin/cozsftp  $ssh_opts  -b- $remoteuser@$server <<EOB
put //DD:UPLOAD4 $remotepath$remotefile4
with the variables defined as

Code: Select all

server="<DNS name>" 
remoteuser="<name>"
remotepath="/sap_stage/DEC/conv/qtc/"
remotefile4="OM03495.DT100822"
following the password exchange:

Code: Select all

export PASSWD_DSN='PDS.DATASET(MEM)'
export SSH_ASKPASS=$coz_bin/read_passwd_dsn.sh
export DISPLAY=none
To support sending various multiple datasets to one of four servers with potentially different user names and passwords I would like to use the same PDS with different members for the various server user names and passwords, e.g., PDS.DATASET(USER1), PDS.DATASET(PASS1). I can't figure out how to get the contents of PDS.DATASET(USER1) assigned to the "remoteuser" variable and the dataset name PDS.DATASET(PASS1) assigned to PASSWD_DSN for the export and SSH_ASKPASS invocation. (I would prefer to use all variables so the user does not have to modify the "export PASSWD_DSN=..." statement.

(BTW, FTP/SFTP and z/OS UNIX is a whole new learning experience for me so I need the 101-level answer and explanation.) :?

THX
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

One approach would be to just to put the variable-setting lines in a PDS member, and then just concatenate the STDIN DD to include that member (first).
Randy
Posts: 16
Joined: Thu Jul 08, 2010 1:36 pm

Post by Randy »

Thanks for your response, but I'm not sure I understand what you are suggesting. :? I think your solution is to specify a PDS member in the JCL that consists of the variable settings. That would mean the end user has to undertand how to modify these variable settings -- that is what I'm tring to avoid. What am I missung?

I want the end user to be able to maintain 2 PDS members per target -- 1 with the 8 character USERID and 1 with the 8 character password. What I need help with is creating the SFTP command stream to get the USERID from the PDS member into the "remoteuser" variable and the password to the SSH_ASKPASS facility.

I'm trying to supply the end user one area of varaibles in the command stream (see the 2nd code snipppet in my original post) so he or she does not have to change any commands, e.g., the "export PASSWD_DSN='PDS.DATASET(MEM)'" command.
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Randy,

I'm still not certain exactly how you intend for the user to provide the input, but here's an example that takes our sample JCL "RUNSFTP" and makes it into a PROC:

Code: Select all

//SFTPPROC PROC PDS=COZUSER.SFTP.PARM,
//         PASSMBR=,
//         USERMBR=     
//SFTP EXEC PGM=COZBATCH,
//          PARM='/PDS=&PDS PM=&PASSMBR UM=&USERMBR'
//STDIN DD *
# Customize these ... 
coz_bin="/opt/dovetail/coz/bin" 
remoteuser=$($coz_bin/fromdsn $PDS\($UM\)) 
server="remote.host.name" 
servercp="ISO8859-1" 
remotefile="/path/to/file" 
                                                                            
# These can be used to read the ssh password from a (secured) dataset 
# if you don't want to setup public/private keypairs 
export PASSWD_DSN="$PDS\($PM\)"
export SSH_ASKPASS=$coz_bin/read_passwd_dsn.sh 
export DISPLAY=none 

(The rest as in the original)
// PEND
So, in this example there are a couple of "tricks" -
1) the PARM= on COZBATCH is used to set environment variables from PROC vars.
2) the line "remoteuser=..." uses our fromdsn command to read the contents of a member into a shell variable using $( ) to capture stdout into a string.
Randy
Posts: 16
Joined: Thu Jul 08, 2010 1:36 pm

Post by Randy »

I think fromdsn and your examples answer my question. :) I'll test later today or early next week.

One more question, is there a command to display the contents of a variable?
We're having USERID and password issues with the group that supports the target UNIX box and it would be helpful if I could cut and paste into an email what I am sending as USERID and password.

THX
Post Reply