Re: Capturing DCL output in symbol

Liste des GroupesRevenir à co vms 
Sujet : Re: Capturing DCL output in symbol
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vms
Date : 13. May 2025, 17:16:42
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vvvr99$1tp72$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 5/10/2025 7:40 AM, hb0815 wrote:
On 5/10/25 03:53, David Meyer wrote:
I was wondering if I could use PIPE to do the same thing without having
to create and later clean up the temporary file, but so far I have been
unable to fine a way to get READ inside a PIPE to set a symbol that's
accessible outside the PIPE command.
 Using PIPE: to capture the output of a (DCL) command you need a "pipeline", that is you need "|". For each pipeline you get a sub- processes. Within the sub-process you can assign a DCL symbol with READ. But a symbol in a sub-process is not propagated to the main process. You have to take a detour via a logical name in the job table to get the symbol value into a symbol of the main process.
 $ del/symb t
%DCL-W-UNDSYM, undefined symbol - check validity and spelling
$ pipe show time | -
   (read sys$pipe t ;qt=""""+f$fao("!AS",t)+"""" ;def/job/nolog t &qt) -
   ;t=f$trnlnm("t")
$ sh symb t
   T = "  10-MAY-2025 10:21:19"
$
 As you can see, the PIPE command contains a sequence of two pipelines and a DCL command. The second pipeline is a subshell. The logical is defined in the sub-process of the second pipeline. The subshell is required or you will not have access to the symbol read by READ. The DCL command runs in your main process. Translating the logical name into a (local) symbol makes its value available in the main process.
 There are limitations. This can only work if the equivalence string of the logical name is valid, does not exceed a limit, etc.
 If your output is a DCL token, then you do not need the quoting (in qt).
 And yes, you need the "&" for the "define". If you use 't' the symbol is evaluated when you enter the command and not when the define is executed.
That is brilliant!
I tried stuffing it in a COM file:
$ vf='f$verify(0)'
$ pipe 'p1' | -
   (read sys$pipe lin ; qlin=""""+lin+"""" ; def/job/nolog res &qlin) ; -
   'p2'==f$trnlnm("res")
$ if vf then exit f$verify(1)+1
$ exit 1
So I can do:
$ @cmd2sym "show time" t
$ sh symb t
   T == "  13-MAY-2025 12:11:57"
$ @cmd2sym "type z.txt" t
$ sh symb t
   T == "A"
Arne

Date Sujet#  Auteur
10 May 25 * Capturing DCL output in symbol20David Meyer
10 May 25 +* Re: Capturing DCL output in symbol12David Meyer
10 May 25 i+* Re: Capturing DCL output in symbol6Henry Crun
10 May 25 ii+* Re: Capturing DCL output in symbol3David Meyer
10 May 25 iii`* Re: Capturing DCL output in symbol2Henry Crun
10 May 25 iii `- Re: Capturing DCL output in symbol1David Meyer
10 May 25 ii+- Re: Capturing DCL output in symbol1David Meyer
10 May 25 ii`- Re: Capturing DCL output in symbol1bill
11 May 25 i`* Re: Capturing DCL output in symbol5Craig A. Berry
12 May 25 i +* Re: Capturing DCL output in symbol3bill
12 May 25 i i`* Re: Capturing DCL output in symbol2Craig A. Berry
12 May 25 i i `- Re: Capturing DCL output in symbol1David Meyer
13 May 25 i `- Re: Capturing DCL output in symbol1Arne Vajhøj
11 May 25 +- Re: Capturing DCL output in symbol1David Meyer
13 May 25 +* Re: Capturing DCL output in symbol2Arne Vajhøj
14 May 25 i`- Re: Capturing DCL output in symbol1Robert A. Brooks
14 May 25 `* Re: Capturing DCL output in symbol4Lawrence D'Oliveiro
14 May 25  `* Re: Capturing DCL output in symbol3Arne Vajhøj
14 May 25   +- Re: Capturing DCL output in symbol1Arne Vajhøj
14 May 25   `- Re: Capturing DCL output in symbol1hb0815

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal