I've asked this before, but I haven't had a definitive answer:
I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.
The first two are simple, but I haven't had any success with the third.
Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?
Andy Styles
andy....@natwest.com
---------------------------------------------------------------------------
The contents of this e-mail may be privileged and are confidential. It may not be disclosed to or used by anyone other than the addressee(s), nor copied in any way. If received in error, please advise the sender, then delete it from your system.
National Westminster Bank Plc is regulated by the Personal Investment Authority and IMRO for investment business. A member of the NatWest and Gartmore Marketing Group advising on the life assurance, pensions and unit trust products only of that Marketing Group.
Registered Office: 41 Lothbury London EC2P 2BP
Registered Number: 929027 England
---------------------------------------------------------------------------
PARSE SOURCE should return it (in the 5th token)
--
John Dexter
Westfarthing Ltd; IT Consultants
-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]On Behalf
Of Andy Styles
Sent: Tuesday, February 08, 2000 9:44 AM
To: TSO-...@VM.MARIST.EDU
Subject: REXX Source Dataset from within REXX
Importance: Low
Hi folks,
I've asked this before, but I haven't had a definitive answer:
I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.
The first two are simple, but I haven't had any success with the third.
Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?
Andy Styles
O. E.
JB Peterson <JB_Pe...@bmc.com> on 02/08/2000 12:19:48 PM
Please respond to JB_Pe...@bmc.com
To: TSO-...@VM.MARIST.EDU
cc: (bcc: O E Jordan/TPC/SA/HARCOURT)
Subject: Re: REXX Source Dataset from within REXX
Parse Source Tokens /* Get source variables */
Parse Var Tokens tsocmd , /* Start command */
cmdfunc , /* Command function */
ename , /* EXEC name */
execdd , /* EXEC lib DDNAME */
execdsn , /* EXEC lib DSNAME */
junk /* Everything else */
-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]On Behalf
Of Andy Styles
Sent: Tuesday, February 08, 2000 9:44 AM
To: TSO-...@VM.MARIST.EDU
Subject: REXX Source Dataset from within REXX
Importance: Low
Hi folks,
I've asked this before, but I haven't had a definitive answer:
I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.
The first two are simple, but I haven't had any success with the third.
Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?
Andy Styles
PARSE SOURCE will only return the name of the data set if the exec
was explicitly invoked, for example, TSO EX 'MY.REXXLIB(PGMA)'. If the
program was invoked implicitly, for example, TSO %PGMA, it will
show a question mark (?).
Mark
--
+--------------------------------+--------------------------------+
| Mark Zelden | OS/390 Consultant |
| http://www.flash.net/~mzelden/ | 3D Business Solutions |
| mailto:mze...@flash.net | mailto:mze...@3dsolutions.com |
+--------------------------------+--------------------------------+
Check out my MVS utilities page at:
http://www.flash.net/~mzelden/mvsutil.html
>PARSE SOURCE will only return the name of the data set if the exec
>was explicitly invoked, for example, TSO EX 'MY.REXXLIB(PGMA)'. If the
>program was invoked implicitly, for example, TSO %PGMA, it will
>show a question mark (?).
...and at that point you are reduced to "LISTA ST" to find out which
datasets are allocated to SYSEXEC and SYSPROC (don't forget about
ALTLIB), walking the lists looking for the first occurrence of the
execname. If done carefully this can deliver the dataset name, but
it's a lot of work for a return of only 44 bytes...
And the code has to be embedded in whatever exec/clist because if it
calls an external routine...
Actually, I'm surprised that MarkZ doesn't have some pro forma code on
his excellent website. If I write it will you post it?
Frank Clarke
Member of the REXX Language Association
Join us at http://www.rexxla.org
>Can anyone tell me how to (definitively) get the name of the dataset from
>where the exec was loaded ?
Definitively? No, but here is my best guess. I haven't tried it as an
external function or with altlib. Thanks, as always, to Gilbert
Saint-flour for the swareq subroutine.
/* REXX - example to find where code was run from. */
/* It assumes cataloged data sets. Not well tested either. */
/* */
/* Doug Nadel */
/* With SWA code lifted from Gilbert Saint-flour's SWAREQ exec */
/* */
Say find_origin() /* say where this was executed
from */
Exit
find_origin:
Procedure
answer='* UNKNOWN *' /* assume disaster */
Parse Source . . name dd ds . /* get known info */
Call listdsi(dd 'FILE') /* get 1st ddname from file */
Numeric digits 10 /* allow up to 7FFFFFFF */
If name = '?' Then /* if sequential exec */
answer=''''ds'''' /* use info from parse source */
Else /* now test for members */
If sysdsn(''''sysdsname'('name')''')='OK' Then /* if in 1st ds */
answer=''''sysdsname'('name')''' /* go no further */
Else /* hooboy! Lets have some fun!*/
Do /* scan tiot for the ddname */
tiotptr=24+ptr(12+ptr(ptr(ptr(16)))) /* get ddname array */
tioelngh=c2d(stg(tiotptr,1)) /* nength of 1st entry */
Do Until tioelngh=0 | tioeddnm = dd /* scan until dd found */
tioeddnm=strip(stg(tiotptr+4,8)) /* get ddname from tiot */
If tioeddnm <> dd Then /* if not a match */
tiotptr=tiotptr+tioelngh /* advance to next entry */
tioelngh=c2d(stg(tiotptr,1)) /* length of next entry */
End
If dd=tioeddnm Then /* if we found it, loop through
the data sets doing an swareq
for each one to get the
dsname */
Do Until tioelngh=0 | stg(4+tiotptr,1)<> " "
tioejfcb=stg(tiotptr+12,3)
jfcb=swareq(tioejfcb) /* convert SVA to 31-bit addr */
dsn=strip(stg(jfcb,44)) /* dsname JFCBDSNM */
vol=storage(d2x(jfcb+118),6) /* volser JFCBVOLS (not used) */
If sysdsn(''''dsn'('name')''')='OK' Then /* found it? */
Leave /* we is some happy campers! */
tiotptr=tiotptr+tioelngh /* get next entry */
tioelngh=c2d(stg(tiotptr,1)) /* get entry length */
End
answer=''''dsn'('name')''' /* assume we found it */
End
Return answer
ptr: Return c2d(storage(d2x(Arg(1)),4))
stg: Return storage(d2x(Arg(1)),Arg(2))
swareq:
Procedure
If right(c2x(Arg(1)),1) \= 'F' Then /* SWA=BELOW ? */
Return c2d(Arg(1))+16 /* yes, return sva+16 */
sva = c2d(Arg(1)) /* convert to decimal */
tcb = c2d(storage(21c,4)) /* TCB PSATOLD */
tcb = ptr(540) /* TCB PSATOLD */
jscb = ptr(tcb+180) /* JSCB TCBJSCB */
qmpl = ptr(jscb+244) /* QMPL JSCBQMPI */
qmat = ptr(qmpl+24) /* QMAT QMADD */
Do While sva>65536
qmat = ptr(qmat+12) /* next QMAT QMAT+12 */
sva=sva-65536 /* 010006F -> 000006F */
End
Return ptr(qmat+sva+1)+16
Doug Nadel
----------------------------------------
ISPF and OS/390 Tools & Toys page:
http://somebody.home.mindspring.com/
Here goes:
.
.
wrcalib = FindMe()
.
FindMe:
x=outtrap('l.')
address tso "lista"
x=outtrap('off')
do i=l.0 to 1 by -1
if pos(".",l.i)=0 then iterate
d="'"l.i"(WRCMAIN)'"
if sysdsn(d)="OK" then return l.i
end
return ""
rgds
Willy
> .
> .
> wrcalib = FindMe()
> .
>
> FindMe:
> x=outtrap('l.')
> address tso "lista"
> x=outtrap('off')
> do i=l.0 to 1 by -1
> if pos(".",l.i)=0 then iterate
> d="'"l.i"(WRCMAIN)'"
> if sysdsn(d)="OK" then return l.i
> end
> return ""
This is really a very easy to use example,
but in some circumstances a problem might occur:
If the dataset's allocated to ISPPLIB are listed
prior to the SYSPROC, SYSEXEC or altlib'ed dataset's
AND there is a panel with the REXX's name the function
returns the name of the panel-dataset...
regards
Frank
Ron MacRae, Amdahl UK.
5 *-* parse source p1 p2 p3 p4 p5 p6 p7
>>> "TSO"
>>> "COMMAND"
>>> "ANEXEC"
>>> "SYSEXEC"
>>> "?"
>>> "?"
>>> "TSO ISPF ?"
Frank Lindenblatt wrote in message ...
rgds
Willy
When I need to look for CLISTS/EXEC locations now, I always
use ISRDDN. I haven't needed this functionality in any programs that
I've written (yet). If I did, I probably would put some kind of code
to ensure that the REXX was executed explicitly, so PARSE SOURCE
could be used reliably - like checking for the ?, and if it was
exit the exec with an error msg.
>There is one other situation I've encountered, if the EXEC resides in a
>function package, then the DD name is '?' as well!
>
I tested the code I put up yesterday as an external function. It
works there too. I haven't tried it from load module yet, but it
should work OK there too unless it is LINKLIST or LPA if that is
possible. That would just be another ELSE condition to search the
LPDEs and LINKLIST libs though, I guess. I just hate the idea of
parsing output meant for human reading (if you can call LISTA ST that
- it has to be one of the most unreadable listings I've ever seen).
I've written several of those execs over the years, but Thanks to
Gilbert's SWAREQ code, those days are over! Whheeee!!!!!
(By the way, using the same TIOT logic, I threw together an edit macro
that generates JCL for running ISPF in batch based on your current
allocations. Kind of neat. Not totally polished yet...
ftp://www.mindspring.com/pub/users/somebody/batchpdf.txt
I'll put a note on ispf-l and a link on my page when it I think it is
done, though it probably just needs a prologue and better attribution)
In article <87s47f$r...@chronicle.concentric.net>, Ron_M...@amdahl.com
says...
> If the DSN, in Parm 5 is "?" then P4 should be the DDNAME the exec was
> loaded from.
>
> Ron MacRae, Amdahl UK.
>
--
Robert Ngan
CSC Financial Services Group
Shmuel (Seymour J.) Metz
> -----Original Message-----
> From: Doug Nadel [SMTP:some...@MINDSPRING.COM]
> Sent: Wednesday, February 09, 2000 11:24 PM
>
> On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
>
> >There is one other situation I've encountered, if the EXEC resides in a
> >function package, then the DD name is '?' as well!
> >
>
I thought it was nice that you could write function routines in REXX and
putting the commonly referenced ones there would really improve
performance (for search/load operations anyway) but it really makes
finding the source dataset convoluted.
In article <vie4asorp6p8do4k1...@4ax.com>,
some...@mindspring.com says...
> On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
>
> >There is one other situation I've encountered, if the EXEC resides in a
> >function package, then the DD name is '?' as well!
> >
>
> I tested the code I put up yesterday as an external function. It
> works there too. I haven't tried it from load module yet, but it
> should work OK there too unless it is LINKLIST or LPA if that is
> possible. That would just be another ELSE condition to search the
> LPDEs and LINKLIST libs though, I guess. I just hate the idea of
> parsing output meant for human reading (if you can call LISTA ST that
> - it has to be one of the most unreadable listings I've ever seen).
> I've written several of those execs over the years, but Thanks to
> Gilbert's SWAREQ code, those days are over! Whheeee!!!!!
>
> (By the way, using the same TIOT logic, I threw together an edit macro
> that generates JCL for running ISPF in batch based on your current
> allocations. Kind of neat. Not totally polished yet...
> ftp://www.mindspring.com/pub/users/somebody/batchpdf.txt
> I'll put a note on ispf-l and a link on my page when it I think it is
> done, though it probably just needs a prologue and better attribution)
>
> Doug Nadel
> ----------------------------------------
> ISPF and OS/390 Tools & Toys page:
> http://somebody.home.mindspring.com/
>
--
In article <0D93FE5CA0BED11194CB...@nsfmail01.nsf.gov>,
sm...@NSF.GOV says...
> The term "function packages" implies multiple functions associated with a
> single member name. Would parse source return the name of the function or
> the name of the package?
>
> Shmuel (Seymour J.) Metz
>
> > -----Original Message-----
> > From: Doug Nadel [SMTP:some...@MINDSPRING.COM]
> > Sent: Wednesday, February 09, 2000 11:24 PM
> >
> > On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
> >
> > >There is one other situation I've encountered, if the EXEC resides in a
> > >function package, then the DD name is '?' as well!
> > >
> >
> > I tested the code I put up yesterday as an external function. It
> > works there too. I haven't tried it from load module yet, but it
> > should work OK there too unless it is LINKLIST or LPA if that is
> > possible.
>
--
>I just ran a test with a function package routine, the returned exec name
>is '?' so you don't know the exec name, ddname or dataset name!
What do you get for the other values? eg: parse source xx;say xx
In article <pra6asstod7p3kp6p...@4ax.com>,
some...@mindspring.com says...
--
Shmuel (Seymour J.) Metz
However, this is all moot since PARSE SOURCE does not tell you the name
of the exec (i.e. function) when the exec is in a function package. So
what are we going to look for?
In article <0D93FE5CA0BED11194CB...@nsfmail01.nsf.gov>,
sm...@NSF.GOV says...
--