Last active
June 11, 2020 13:10
-
-
Save NielsLiisberg/c60ae8267edd09df94ef4c2fba718268 to your computer and use it in GitHub Desktop.
SQL Create SH command to run PASE shell, script or command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Let SQL create a command and CLLE program to run PASE shell | |
-- scripts or commands - much like QSH but for PASE. Ex. like this: | |
-- | |
-- SH SCRIPT('ls') | |
-- | |
-- Simply paste this gist into ACS SQL and select "run all" | |
-- | |
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library | |
-- It is a cool example how far you can go with SQL: Have fun - | |
-- (C) Niels Liisberg 2020 | |
---------------------------------------------------------------------------------------------- | |
call qcmdexc ('crtsrcpf rcdlen(132) file(qtemp/src) mbr(src)'); | |
delete from qtemp.src; | |
insert into qtemp.src (srcdta) values | |
('CMD PROMPT(''Run PASE script or command'')'), | |
('PARM KWD(SCRIPT) TYPE(*CHAR) LEN(4096) MIN(1) EXPR(*YES) CASE(*MIXED) PROMPT(''Script or command'')'); | |
call qcmdexc ('CRTCMD CMD(QUSRSYS/SH) PGM(QUSRSYS/SH) SRCFILE(QTEMP/SRC) SRCMBR(SRC) REPLACE(*YES)'); | |
delete from qtemp.src; | |
insert into qtemp.src (srcseq,srcdta) values | |
(1,'pgm (&script)'), | |
(2,'dcl var(&shell) type(*char) len(32)'), | |
(3,'dcl var(&c) type(*char) len(3)'), | |
(4,'dcl var(&script) type(*char) len(4096)'), | |
(5,'dcl var(&null) type(*char) len(1) value(x''00'')'), | |
(6,'chgvar &shell (''/QOpenSys/usr/bin/sh'' *tcat &null)'), | |
(7,'chgvar &c (''-c'' *tcat &null)'), | |
(8,'chgvar &script (&script *tcat &null)'), | |
(9,'call pgm(qp2shell) parm(&shell &c &script)'), | |
(10,'endpgm'); | |
call qcmdexc ('CRTBNDCL PGM(QUSRSYS/SH) SRCFILE(QTEMP/SRC) SRCMBR(SRC) REPLACE(*YES)'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment