[Info-vax] Command Procedure Pipe output to a variable
Hein RMS van den Heuvel
heinvandenheuvel at gmail.com
Sat Sep 4 20:57:18 EDT 2021
On Tuesday, August 31, 2021 at 5:49:46 AM UTC-4, HCorte wrote:
> Implementing a command procedure that first obtains the device allocated to a process for example purposes called YYYYYY.
>
> How to output the results of (SEARCH SYS$INPUT "Devices allocated") to the variable DEVICEAUX tried (READ SYS$PIPE DEVICEAUX) but with no success.
>
> $ pipe SH PROCESS YYYYYY | SEARCH SYS$INPUT "Devices allocated" | (READ SYS$PIPE DEVICEAUX)
> $ WRITE SYS$OUTPUT DEVICEAUX
> $ DEVICE_AUX = F$EDIT(F$ELEMENT(1, ":", TEST),"TRIM")
> $ WRITE SYS$OUTPUT DEVICE_AUX
>
> can make it work to write to a file
> $ pipe SH PROCESS SCMLCOMOLM | SEARCH SYS$PIPE "Devices allocated" > DEVICEAUX.DAT
>
> but would prefer to avoid having to write and read from file if possible, also in command procedure should alls use SYS$PIPE instead of SYS$INPUT?
Eisner - HTTP$SERVER
$ perl -e "for (qx(show proc /id=00078E34)) { push @dev,$1 if / (\w+\d+):$/} print join q(,), at dev "
EWA133,BG25512,BG25513,BG25514, ....
or
$ perl -e "for (qx(show proc /id=00078E34)) { push @dev,$1 if / (\w+\d+):$/} $ENV{test} = join q(,), at dev "
$ show log test
"TEST" = "EWA133,BG25512,BG25513,BG25514, ... " (LNM$PROCESS_TABLE)
Narration:
-e = "execute following string as Perl program"
for ( ... ) { ... } = loop over output from whatever is delivered between parens into default variable $_ and execute block each time.
qx = execute in sub-process, delivering to output lines to for loop
block:
push array, element $1
IFF
there is a match ( /.../ ) in value of default variable $_
ON a space (paren to start remembering into $1) followed by some word chars and some numbers (stop remembering) and a colon at end-of-line.
end block
end loop
q(,) = single quoted string = non-interpolated string holding a comma ! Could have used qq(,) as wel for double quoted - no difference in this case.
set associative array ENV (which maps only Logicals and Symbols) element 'test' to become all devices names joined, separated with a comma between each.
Enjoy,
Hein
More information about the Info-vax
mailing list