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
Problem passing variables to a script
Re: Problem passing variables to a script
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.
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.
Re: Problem passing variables to a script
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,
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,
Re: Problem passing variables to a script
I can't explain it - if you didn't continue the ssh command, the script would be executed locally and not remotely via ssh.
Re: Problem passing variables to a script
I can't explain either. Thanks again for your help.
Valter Marguccio
Valter Marguccio