Saturday, October 18, 2014

Command shell (option 6) in mainframe - Executing commands through Terminal Utility program IKJEFT01

Most of us have definitely seen or used in some way or other  the command shell(option 6) from ISPF panel. This is very useful command window. TSO /E allows us to talk to MVS  either through TSO E commands , or the ISPF pannel(like option 6) as i was mentioning above. In some work , i came across a scenario where i need to execute certain commands in command shell.
For example the following  commands:
REMOVE  I1612XX GROUP(MYGROUP) OWNER(MYGROUP)               
REMOVE  I171    GROUP(MYGROUP) OWNER(MYGROUP)               
CONNECT I151    GROUP(MYGROUP) OWNER(MYGROUP) AUTHORITY(USE)
CONNECT I151    GROUP(MYGROUP) OWNER(MYGROUP) AUTHORITY(USE)
The simplest way is to to go to ISPF and go to option 6. Then execute each command manually .

But the tweek in my case was to execute these commands in  batch and collect the command logs, ie, whether these commands were executed or not and all details.

So, here is the utility IKJEFT01 which we can use. Its other name is terminal utility program.
Whatever we want to execute in the pannel screen can be executed from batch as well using ikjeft01.
So, lets have the JCL for  using this utility.
Way1
//STEP001  EXEC PGM=IKJEFT01                
//SYSTSIN  DD   DSN=Your-Dataset,DISP=SHR
//SYSTSPRT DD   SYSOUT=*
Way 2
//STEP002    EXEC PGM=IKJEFT01             
//SYSTSPRT DD SYSOUT=*                     
//SYSTSIN  DD  *                           
    tso commands here


your-dataset would be the ps file having all the commands which needs to be executed
or  give all the commands in SYSTSIN DD *

Now if we explore further we can use this utility to perform many functions which in some cases may turn out to be very useful
Few useful commands which we can perform  in batch
1. Rename a dataset
2. Copy a file to some new name  (we can use other  ibm utilities as well)
3. Copy pds member to a new pds with a new name or same name
4 . Check job status and many other useful functions.
There are lot many others as well...
Have a look into jobs for some of the functions:
//STEP001    EXEC PGM=IKJEFT01                  
//SYSTSPRT DD SYSOUT=*                          
//SYSTSIN  DD  *                                
   SMCOPY FDS('USER12.JCL(TEST1)')  -           
          TDS('USER22.SAS(TEST2)') NOTRANS      

//SYSPRINT DD  SYSOUT=*                         
//SYSIN    DD  DUMMY                            
//* *****copy files                                            
//STEP002    EXEC PGM=IKJEFT01                  
//SYSTSPRT DD SYSOUT=*                          
//SYSTSIN  DD  *                                
   SMCOPY FDS('USER-ID.TST.FILE1')  -           
          TDS('USER-ID.TST.FILE2.FILE3') NOTRANS

//SYSPRINT DD  SYSOUT=*                         
//SYSIN    DD  DUMMY                            
 The  first step STEP001 copies pds members to other pds
The next step,STEP002 copies files
SMCOPY is the command to copy. FDS and TDS means From dataset and To dataset respectively.
Will explore some more and update as time permits!.

No comments:

Post a Comment