Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 28 |
Nodes: | 6 (0 / 6) |
Uptime: | 67:44:47 |
Calls: | 425 |
Calls today: | 3 |
Files: | 1,025 |
Messages: | 91,518 |
Posted today: | 1 |
I found that one way to do it is to put all the processing that uses the command output inside subshells in the same PIPE command.
One shortcoming of this method is that it's very easy to go over the
maximum command element length allowed inside the PIPE. For my
procedure, I was able to get around this by choosing lexical functions
to minimize the length of the PIPE command.
Any other way to do this?
try e.g.
$ count=$( dir *.sh | wc -l )
$ echo $count
25
Henry Crun <mike@rechtman.com> writes:
try e.g.
$ count=$( dir *.sh | wc -l )
$ echo $count
25
I get an undefined symbol error for \$\ on OpenVMS V8.3. Does your trick require a newer version of VMS?
Apologies!!
Ignore my post - I was in the wrong newssgroup.
...Senior moment ;-(
...
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.
...
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.
I found that one way to do it is to put all the processing that uses the command output inside subshells in the same PIPE command.
One shortcoming of this method is that it's very easy to go over the
maximum command element length allowed inside the PIPE. For my
procedure, I was able to get around this by choosing lexical functions
to minimize the length of the PIPE command.
Any other way to do this?
On 5/11/2025 3:17 PM, Craig A. Berry wrote:
On 5/9/25 11:32 PM, David Meyer wrote:
I found that one way to do it is to put all the processing that uses the >>> command output inside subshells in the same PIPE command.
One shortcoming of this method is that it's very easy to go over the
maximum command element length allowed inside the PIPE. For my
procedure, I was able to get around this by choosing lexical functions
to minimize the length of the PIPE command.
Any other way to do this?
It's pretty easy with Perl:
$ perl -"MVMS::DCLsym" -e "$x=`show time`; VMS::DCLsym-
setsym('mysym', $x, 'GLOBAL');"$ SHOW SYMBOL mysym
  MYSYM == "  11-MAY-2025 14:10:89."
It's probably easy to do in a lot of scripting languages.
But the original request specified DCL. Might be he
expects the script to have to run on machines that only
have VMS on them.
On 5/11/25 6:24 PM, bill wrote:
On 5/11/2025 3:17 PM, Craig A. Berry wrote:
It's pretty easy with Perl:It's probably easy to do in a lot of scripting languages.
[...]
But the original request specified DCL. Might be he
expects the script to have to run on machines that only
have VMS on them.
On OpenVMS x86, Perl is part of the base install, so it's always there.
On 5/9/25 11:32 PM, David Meyer wrote:
I found that one way to do it is to put all the processing that uses the
command output inside subshells in the same PIPE command.
One shortcoming of this method is that it's very easy to go over the
maximum command element length allowed inside the PIPE. For my
procedure, I was able to get around this by choosing lexical functions
to minimize the length of the PIPE command.
Any other way to do this?
It's pretty easy with Perl:
$ perl -"MVMS::DCLsym" -e "$x=`show time`; VMS::DCLsym->setsym('mysym',
$x, 'GLOBAL');"
$ SHOW SYMBOL mysym
 MYSYM == "  11-MAY-2025 14:10:89."
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.
On 5/10/2025 7:40 AM, hb0815 wrote:
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.
That is brilliant!
There are limitations. This can only work if the equivalence string of
the logical name is valid, does not exceed a limit, etc.
On Sat, 10 May 2025 13:40:45 +0200, hb0815 wrote:
There are limitations. This can only work if the equivalence string of
the logical name is valid, does not exceed a limit, etc.
You have to choose a logical name that won’t clash with any other use in any other process in the same job, you have to remember to delete it afterwards to avoid clutter ...
On 5/14/2025 5:31 AM, Lawrence D'Oliveiro wrote:
On Sat, 10 May 2025 13:40:45 +0200, hb0815 wrote:
There are limitations. This can only work if the equivalence string of
the logical name is valid, does not exceed a limit, etc.
You have to choose a logical name that won’t clash with any other use in >> any other process in the same job, you have to remember to delete it
afterwards to avoid clutter ...
That is not so hard.
$ vf='f$verify(0)'
$ reslog = "RES_" + f$unique()
$ pipe 'p1' | -
 (read sys$pipe lin ; qlin=""""+lin+"""" ; def/job/nolog 'reslog'
&qlin) ; -
 'p2'==f$trnlnm(reslog)
$ deas/job 'reslog'
$ if vf then exit f$verify(1)+1
$ exit 1
On 5/14/2025 5:31 AM, Lawrence D'Oliveiro wrote:
On Sat, 10 May 2025 13:40:45 +0200, hb0815 wrote:
There are limitations. This can only work if the equivalence string of
the logical name is valid, does not exceed a limit, etc.
You have to choose a logical name that won’t clash with any other use in >> any other process in the same job, you have to remember to delete it
afterwards to avoid clutter ...
That is not so hard.
...