Problem passing variables to a script

Discussion of the COZBATCH utility for z/OS
Post Reply
marguccio
Posts: 18
Joined: Fri Feb 14, 2014 9:09 am

Problem passing variables to a script

Post by marguccio »

Hello support,
I'm having a problem passing variables to a script. This simple jcl does pass variable "subdir"
to a ls command:

//SAMPLE PROC SD=''
//LIST EXEC PGM=COZBATCH,PARM='/subdir=&SD'
//STDIN DD *
#
ls -lisa /u/MYUSER/$subdir
#
// PEND
//*
//STEP1 EXEC SAMPLE,SD='gino'
//*

this jcl does NOT pass variable "COUNTRY" to a script which resides on a Linux box:

//TEST PROC C=''
//SSHDD EXEC PGM=COZBATCH,PARM='COUNTRY=&C'
//SYSOUT DD SYSOUT=*
//STDENV DD DSN=SYS2.TABLIB(ENSTDENV),DISP=SHR
//STDIN DD *
ssh -T myuser§mylinux
/usr/bin/myscript.sh firstparm secondparm $COUNTRY
// PEND
//*
//STEP1 EXEC TEST,C='DE'
//*

I can't see why. Your help is appreciated.

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

Re: Problem passing variables to a script

Post by dovetail »

COZBATCH is written in C/C++ and therefore uses the z/OS Language Environment (LE).

With LE, anything before the first "/" in PARM= is taken as a LE runtime option.

So, as shown in the sample JCL RUNCOZB, you want to have PARM= start with "/".

So, try this instead:
//SSHDD EXEC PGM=COZBATCH,PARM='/COUNTRY=&C'

Also, I suggest that you can add the "-LT" option to get diagnostic information from the COZBATCH utility.
This will tell you want the environment variables are before the z/OS Unix shell is invoked.
Example:
//SSHDD EXEC PGM=COZBATCH,PARM='/-LT COUNTRY=&C'

Finally, you can get a trace of commands executed by your z/OS Unix shell script by adding the following to the beginning of the script (the first line after //STDIN DD *):

set -x

Also, I'm not sure what you are trying to do, but do you want to run "/usr/bin/mscript.sh .... " remotely via ssh?
If so, you will need to add a "\" continuation character to the end of the line containing the ssh command.
marguccio
Posts: 18
Joined: Fri Feb 14, 2014 9:09 am

Re: Problem passing variables to a script

Post by marguccio »

Hello dovetail,

I added a "/" before my variable in the PARM=; furthermore, I added the continuation char "\"
between the ssh command and the script . Now it works, variable is passed. THANKS!!

I'm confused on the "\" in STDIN, though. We have been using COZBATCH for almost three years
in order to kick ant script residing on Linux box(es) using a z/OS job. In most of our STDIN the content is:

ssh myuser§mylinux
/usr/bin/myscript parm1 parm2

without "\" at the end of the first line. Despite the missing "\", the script(s) get executed. Why ?

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

Re: Problem passing variables to a script

Post by dovetail »

I can't explain it - if you didn't continue the ssh command, the script would be executed locally and not remotely via ssh.
marguccio
Posts: 18
Joined: Fri Feb 14, 2014 9:09 am

Re: Problem passing variables to a script

Post by marguccio »

I can't explain either. Thanks again for your help.

Valter Marguccio
Post Reply