Skip to content

Instantly share code, notes, and snippets.

View lbdyck's full-sized avatar

Lionel B. Dyck lbdyck

View GitHub Profile
@lbdyck
lbdyck / tsocmds
Last active April 5, 2024 15:40
Show how to use a STEPLIB for the USS tsocmd
#!/bin/sh
# this short shell script will allow the shell user to invoke
# any TSO command that resides in a load library that is not
# in the STEPLIB or Link List.
#
# Change the hlq.load.library to your load library and enjoy
#
# Copy into a directory in your PATH to use as a shell command
# and issue chmod +x xxxxx (where xxxxx is the name you gave to
@lbdyck
lbdyck / addcomma.rex
Created December 4, 2023 18:48
Add Comma to any Number
AddComma: Procedure /* Code provided by Doug Nadel back before the turn of the century */
arg bignum
cbignum = strip(translate('0,123,456,789,abc,def,ghi,jkl,mno,pqr,stu,vwx', ,
right(bignum,34,','), ,
'0123456789abcdefghijklmnopqrstuvwx'),'L',',')
return cbignum
@lbdyck
lbdyck / swapeq.rex
Last active June 9, 2023 19:05
SWAPEQ - ISPF Edit Macro to swap sides on an = statement
/* --------------- REXX ------------------ *
| SwapEQ - Swap the sides of an = setting |
| a = b |
| becomes |
| b = a |
* --------------------------------------- */
Address ISREdit
"Macro (range) NOPROCESS"
"PROCESS RANGE S"
"(start) = linenum .zfrange"
@lbdyck
lbdyck / fileExist.rex
Last active May 27, 2023 17:58
REXX to test the existence of a OMVS File
/* --------------------- REXX ---------------------- *
| This is a sample routine using REXX to deternmine |
| if a file exists within OMVS. |
* ------------------------------------------------- */
file = '~/.profile'
rc = exist(file)
if rc > 0 then say 'File exists'
else say 'File does not exist'
file = 'bad.file'
rc = exist(file)
@lbdyck
lbdyck / sleep.rex
Created May 25, 2023 16:41
How to Sleep in REXX
/* rexx */
/* call USS sleep routine */
parse arg sleep_sec .
say time()
address 'SYSCALL' 'SLEEP ('sleep_sec')'
say time()
return 0
@lbdyck
lbdyck / update_anycase.rex
Created May 25, 2023 14:47
Enable Any Case Search with SRCHFOR when using DSLIST
/* ---------------------------------------------------- *
| Change the zus4anyc (SRCHFOR default) to selected (/) |
| if it is null with option Set. |
| Or option Reset restore it. |
| |
| Use this before and after thus: |
| |
| Address ISPExec |
| call check_anyc 'SET' |
| "LMDINIT LISTID(LISTID) LEVEL("hlq"."file_pfx"*)" |
/* This routine will test if the active user has the
ability to access UID 0 (superuser)
*/
Check_UID0:
address syscall 'geteuid' /* get current euid */
euid = retval
address syscall 'seteuid 0' /* try to set uid 0 */
if retval /= 0 then do
gooduid0 = 1
@lbdyck
lbdyck / grepzos.rex
Created April 5, 2023 14:22
Use Grep to search a z/OS Dataset
Sample REXX code to use grep to search a z/OS sequential dataset for a string:
/* rexx */
arg file string
x = searchstring(file,string)
if x = 0 then do
say 'No results found for:' string
exit 4
end
do i = 1 to results.0
@lbdyck
lbdyck / ehex.rex
Last active May 29, 2023 15:21
ISPF Edit Macro to display a record in hex
/* ---------------------- REXX ----------------------------- *
| ISPF Edit Macro to display the requested record in hex in |
| an infoline. (Note: no validation is performed) |
| |
| Syntax: EHEX line |
| |
| Where EHEX is the macro name (change as you wish) |
| line is a record number |
| |
| Sample: EHEX 4 |
@lbdyck
lbdyck / labdel.rex
Last active December 15, 2022 13:51
ISPF Edit Macro to Add or Remove a label
/* ------------------------- REXX ------------------------------ *
| LABDEL: Sample REXX code to set a label and to remove a label |
| based upon the provided parm. |
| |
| Syntax: labdel option |
| |
| option value: null - add the label |
| anything else - remove the label |
| |
* ------------------------------------------------------------- *