Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

PIPE Cmd Issue

 
SOLVED
Go to solution
Highlighted
Jack Trachtman
Super Advisor

PIPE Cmd Issue

Un*x versions of the PIPE cmd usually allow output to be appended to a file. The DCL PIPE cmd only seems to allow output redirection to a new file.

Question 1) Any way to get PIPE to append to a file?

Question 2) In trying to create an equivalent append function, I ran into something I don't understand.

This script works:

$ OPEN/APPEND OUT X.LOG
$ PIPE SHOW TIME > OUT
$ CLOSE OUT

But this script fails - why? (Only differnce is the pair of parenthesis)

$ OPEN/APPEND OUT X.LOG
$ PIPE ( SHOW TIME ) > OUT
%DCL-W-WRGSUBSHSYN, empty subshell or subshell is not separated from other command sequences by proper separators
$ CLOSE OUT
4 REPLIES 4
Ph Vouters
Valued Contributor

Re: PIPE Cmd Issue

DCL is not compatible with sh or ksh or bash. Commands between () have special meaning on these Unix shells.

By the way, pipe has more progress to do. In one line the command:
$ PIPE SHOW TIME >> X.LOG
does not work on OpenVMS V8.3-1H1 with HP I64VMS VMS831H1I_UPDATE V6.0. I do not know what with OpenVMS V8.4 !
John Gillings
Honored Contributor
Solution

Re: PIPE Cmd Issue

Jack,

> Question 1) Any way to get PIPE to append to a file?

Sure, easy:

$ PIPE somecommand | APPEND SYS$PIPE somefile

Yes, it would have been nice if DCL had implemented this with ">>" like Unix, but they didn't.

> But this script fails - why? (Only
> differnce is the pair of parenthesis)

It's syntactically incorrect. The brackets delimit a subshell. Redirection "belongs" to a subshell, so it would need to be included inside the brackets to be syntactically correct.

Where DCL gets a bit ugly is in working out how to redirect output for a "whole" subshell. Consider:

$ PIPE (SHOW TIME ; SHOW PROCESS)

How to send the output for the whole subshell?

As you've shown, the obvious syntax is incorrect:

$ PIPE (SHOW TIME ; SHOW PROCESS) > myfile

I'd agree that this SHOULD work, but the way the syntax is designed it doesn't.

Changing to:

$ PIPE (SHOW TIME ; SHOW PROCESS > myfile)

but this only catches the output for the immediately preceeding command.

You can use COPY, like this:

$ PIPE (SHOW TIME ; SHOW PROCESS) | COPY SYS$PIPE myfile

The DCL PIPE command is only a bit like the Unix one. It has some very strange quirks and limitations.

For example, one of the primary motivations for pipe in Unix is to avoid temporary files and disk I/O, thereby making the script run faster. Although the DCL command avoids disk I/O, it's typically orders of magnitude SLOWER than the same sequence of commands using temporary files. It seems to have something to do with the way the PIPE processes are synchronised (the writer often ends up in RWMBX waiting for the next pipe stage. Resource waits are VERY expensive).

That's not to say PIPE isn't useful, just that it isn't a direct mapping from the Unix function. You should always test your assumptions and reasons for using it.
A crucible of informative mistakes
Jack Trachtman
Super Advisor

Re: PIPE Cmd Issue

Thanks John
Jack Trachtman
Super Advisor

Re: PIPE Cmd Issue

Per John