To check if the latest version of given GDG base has data

Hi All ,

I am trying to run a shell script through a JCL . The requirement is I have a gdg base name and I need to create a script that will just check if the latest version of that gdg has data or not . If it doesnt have data RC 4 need to be returned . One more thing which is bothering me is i need to pass a parameter from the JCL to that script that will be appended at the end of the file . Let me be more clear .

Suppose the file name is PRODGA.GL.DTL&PARM

This would be the JCl :

 
//SD138110 JOB ('ACCT000000','SUMIT'),MSGLEVEL=(1,1),
// CLASS=0,MSGCLASS=X
//*******************************************************************
//* CHECKS FOR THE EXISTENCE OF GDG *
//*******************************************************************
//STEP01 EXEC PGM=GDGCHK,PARM='TEST'
//SYSPRINT DD SYSOUT=X
//SYSTSPRT DD SYSOUT=*
//*

So the Script needs to check for the file PRODGA.GL.DTLTEST_00 (latest version) for the data ....something like

 
#!/bin/ksh
 
$a = "PRODGA.GL.DTL$PARM_00" /// syntax would be changed 
echo "$a" //// jus for checking if PRODGA.GL.DTL$PARM is getting converted to PRODGA.GL.DTLTEST
if [ ! -s $a ];then
echo "**** ERROR - FILE EMPTY ****"
exit 4
fi;
exit

Any sort of help is appreciated and pls let me know if i can provide you guys with some more details which might be needed here.

Thanx in advance ,
Sumit

Hi All ,

I have come up with this script which does the thngs required but in both the cases i.e., whether the file PRODGA.GL.DTLTEST_00 has data or not it gives file empty error . The PARM passed from JCL is TEST

 
#!/bin/ksh

var1="PRODGA.GL.DTL$PARM"  
echo $var1                           //  it shows PRODGA.GL.DTLTEST
var2='_00'
var3=$var1$var2
echo $var3                           // it shows PRODGA.GL.DTLTEST_00
if [ ! -s $var3 ];then
  echo "**** ERROR - FILE EMPTY ****"
  exit 4
fi;
exit

now even if ls -l PRODGA.GL.DTLTEST_00 :

ls -l PRODGA.GL.DTLTEST_00
-rw-rw-r--   1 sd138110 btpso          2 Dec 16 04:03 PRODGA.GL.DTLTEST_00

but this script shws error - file empty

Could anyone please let me know where i am missing .

Are you running the JCL on the MVS side to perform a script on the Unix side? If so why not use the MVS utilities to check if the GDG is empty? Also, you might try posting your problem on this site: MVSFORUMS.com :: Index or do a search their and see what you find. Good Luck.

its workin fine now ...

i tried giving echo $PWD and found out it was looking in some different dir .