HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

DCL Pipe Question

 

DCL Pipe Question

In a naive attempt to replicate

ls -1 | xargs rm

I tried to do

pipe dir/columns=1/noheading/notrailing | delete

This doesn't work - it gives me a missing command parameters error.

Can someone tell me why?

Regards

Patrick.
10 REPLIES
Steven Schweda
Honored Contributor

Re: DCL Pipe Question

Perhaps because DELETE doesn't take its
arguments from stdin/SYS$INPUT any more than
"rm" does. You've omitted the "xargs" from
the VMS version.

DELETE already has the usual raft of file
selection options: wildcard lists, /BEFORE,
/SINCE, and so on. Do you really need to use
DIRECTORY for anything here? DCL does not
work exactly the way a UNIX shell works, so
the best way to solve a problem in one
environment is seldom the best way in the
other.

Or is there some real problem which you are
trying to solve?
Bart Zorn_1
Trusted Contributor

Re: DCL Pipe Question

Patrick,

Most DCL commands do not work in the same way as U**x commands do. The DCL command DELETE expects one parameter, a file specification. It also accepts an indirect specification in the form of @, where is supposed to contain a list of files. I could not find documentation about this, though.

So you might be able to do the following:

pipe dir/columns=1/noheading/notrailing | delete @sys$pipe

However, when I tried it, it deleted only the first file from the pipe and then issued the message
%DCL-W-NOCOMD, no command on line - reenter with alphabetic first character

I will try to find out why.

Regards,

Bart
Steven Schweda
Honored Contributor

Re: DCL Pipe Question

> [...] DELETE expects one parameter, a file
> specification. [...]

Not necessarily one. As the HELP says:

DELETE

file

Parameter

filespec[,...]

Specifies the names of one or more files to be deleted [...]


> I could not find documentation about this,
> though.

http://h71000.www7.hp.com/doc/83FINAL/9996/9996pro_18.html

It's in the fine print:

[...]
To execute a command procedure that contains qualifiers or parameters, or both, for a specific command line,
place the @ command where the qualifiers or parameters normally would be in the command line. Then specify
the name of the command procedure file containing the qualifiers or parameters.
[...]


> I will try to find out why.

DIRECTORY doesn't put out a comma-separated
list of file specs, which is what you'd need
here.
Hakan Zanderau ( Anders
Trusted Contributor

Re: DCL Pipe Question

The format for the command DELETE is

DELETE filespec[,...]

The pipecommand doesn't create a parameterlist, just a list of files.

The first attempt with just DELETE,
says "missing command parameters" and as it says....no parameters is supplied.

The second attempt with "DELETE @SYS$PIPE".
SYS$PIPE is still a list of files, not a parameterlist. The first file (line) is executed, but the next line in the file will be executed as it is.....without any command.

Take a look on "@" in "DCL Dictionary"

=======

To execute a command procedure that contains qualifiers or parameters, or both, for a specific command line, place the @ command where the qualifiers or parameters normally would be in the command line. Then specify the name of the command procedure file containing the qualifiers or parameters.

If the command procedure file begins with parameters for the command, the @ command must be preceded by a space. For example:



$ CREATE TEST.COM
TIME
[Ctrl/Z]
$ SHOW @TEST
14-SEP-2001 17:20:26



If the file begins with qualifiers for the command, do not precede the @ command with a space. For example:



$ CREATE TEST_2.COM
/SIZE
[Ctrl/Z]
$ DIR@TEST_2


Directory WORK$:[SCHEDULE]

JANUARY.TXT;8 14-DEC-2001 15:47:45.57
FEBRUARY.TXT;7 14-DEC-2001 15:43:16.20
MARCH.TXT;6 14-DEC-2001 11:11:45.74
.
.
.
Total of 11 files.



If the file contains parameters or qualifiers, or both, do not begin the lines in the file with dollar signs. Any additional data on the command line following @filespec is treated as parameters for the procedure.

======
Don't make it worse by guessing.........
Bojan Nemec
Honored Contributor

Re: DCL Pipe Question

Patrick,

What aboout a simple command procedure (XARGS.COM):

$ open/read pipe sys$pipe
$loop:
$ read pipe args/end=end
$ 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' 'args'
$ goto loop
$end:
$ close pipe

so you can do:

$ pipe dir/columns=1/noheading/notrailing | @xargs delete

or perhaps

$ pipe dir/columns=1/noheading/notrailing | @xargs delete /confirm


Its a one minute command procedure so its on you to test it and improve

Bojan


Hoff
Honored Contributor

Re: DCL Pipe Question

Picking up an application design for one platform and directly dropping it on another is the root problem here; that's usually a whole lot more work, and the results are often a whole lot less supportable, than using a native design.

OpenVMS pipes are not what you remember from Unix; you'll probably get frustrated pretty quickly here. Many of the OpenVMS DCL verbs aren't set up for nor particularly suited for piping, either. The usual solution is lexical functions, something which OpenVMS has a reasonable set of.

Why not load gnv and do what you want, and the way you want to? gnv provides bash and related, and gives you a reasonable emulation of and the tools of the Bourne shell. And gnv is free, and is provided by HP.

Stephen Hoffman
HoffmanLabs LLC
DECxchange
Regular Advisor

Re: DCL Pipe Question

Hello,
Consider doing a $ help lexical. It gives you a list of Lexical Functions available in DCL. One of them is F$CONTEXT. With this, you can do various things like search for files in a directory. You can use a delete command in a loop. I know that isn't as slick as using a pipe command, but it works. The lexicals are pretty cool, so check 'em out.
Hein van den Heuvel
Honored Contributor

Re: DCL Pipe Question

>> Consider doing a $ help lexical. It gives you a list of Lexical Functions available in DCL.

A fine suggestion.

>> One of them is F$CONTEXT.

Correct.

>> With this, you can do various things like search for files in a directory.

NOT. You can use F$SEARCH for this though, with or without the help of its CONTEXT argument, and with or without the help of F$PARSE.

Patrick> DCL Pipe Question
>Question In a naive attempt to replicate
>ls -1 | xargs r
>I tried to do

Why? Just to try? What problem are you really trying to solve?

fwiw, I would use PERL to do something along the lines requested. For example:

$ pipe dir /col=1 *.tmp | perl -ne "chomp; unlink if /;/"

fwiw,
Hein.






Galen Tackett
Valued Contributor

Re: DCL Pipe Question

> In a naive attempt to replicate

> ls -1 | xargs rm

> I tried to do

> pipe dir/columns=1/noheading/notrailing | delete

> This doesn't work - it gives me a missing > command parameters error.

:-D
On my VMS V7.3-2 system with GNV V1-6.2, the following worked just fine:

$ bash
bash$ ls -1 | xargs rm
bash$
$

But I guess that using GNV to answer this question is cheating!

I also found that the following worked:
$ DELETE *.*;*

:-D

(Please note the smilies!)
Aaron Sakovich
Super Advisor

Re: DCL Pipe Question

Using this command procedure, eachline.com, from dcl.openvms.org:

http://tinyurl.com/2ux77l

You can do this with a single line. I believe the syntax would be:

$ pipe dir/nohead/notrail [filespec] | @eachline file "delete &file"

HTH,
Aaron
P.S. Sorry for having to use TinyURL; this forum prevented me from giving a direct link due to threat of x-site scripting. You might be able to cut-and-paste this, though: dcl.openvms.org/stories.php?story=05/01/21/1424401