Operating System - OpenVMS
1824218 Members
3350 Online
109669 Solutions
New Discussion юеВ

Use a symbol in a DCL command procedure

 
SOLVED
Go to solution
Chaim Budnick
Regular Advisor

Use a symbol in a DCL command procedure

Is it possible to use a DCL symbol with the sys$command of a DCL command procedure?

Example:

$date=f$time()
$monitor
monitor io/sum='date'.sum

This does NOT work as the symbol in this case is not being interpreted by DCL before being passed to the monitor command.

Is there a way, nevertheless, to accomplish this?

Chaim
11 REPLIES 11
Ian Miller.
Honored Contributor

Re: Use a symbol in a DCL command procedure

In your specific example you can do the command
on line line.
$ MONITOR IO/SUM='date'.SUM

Generally no as what is imput in response to the program promp (MONITOR> in this case) is not seen by DCL so can't have symbol subtitution. The classic workaround is to write a temp DCL procedure with the right commands in then execute it and delete it after.
____________________
Purely Personal Opinion
Jan van den Ende
Honored Contributor
Solution

Re: Use a symbol in a DCL command procedure

Chaim, Ian,

Nowadays a very nice option is the PIPE command, using input redirection!

Your example
(including a conversion from date-time to date)

$ PIPE MONITOR < MONITOR IO/SUMM='f$cvtim("","comparison","date")'.sum


Cheers.

Have one on me.

Jan
Don't rust yours pelled jacker to fine doll missed aches.
Ian Miller.
Honored Contributor

Re: Use a symbol in a DCL command procedure

Jan,
nice solution for single line input (worthly of a virtual Duvel Triple :-) but that would not work for multiple line input. I guess (as usual) it depends on what Chaim is really trying to do.
____________________
Purely Personal Opinion
Hein van den Heuvel
Honored Contributor

Re: Use a symbol in a DCL command procedure

Right, datalines are NOT interpreted. No substitutions.

To classic solution for this is to create a temp file, write the datalines to it, close, give to the program as sys$input, delete.
Most variations are in the file name and place (sys$login vs current vs sys$scratch / temp.tmp vs process-name-input.tmp vs PID.tmp

Nowadays you should consider a pipe, as answerred before.

There are also some MAILBOX solutions around.
Use tool to create a mailbox, open, write...

Cheers,
Hein.


Bojan Nemec
Honored Contributor

Re: Use a symbol in a DCL command procedure

Jan,

I'm sorry but I'm not convinced that yours example works properly. By the PIPE definition < is the SYS$INPUT redefinition from an input file. I dont know why yours example works. It seems that the < MONITOR part is not executed so you at end have the same command as Ian. You can try by typing:

$ PIPE MONITOR < EATEN IO/SUMM='f$cvtim("","comparison","date")'.sum

You can substutute EATEN with any other word and the results are the same.

You can use pipe with a temporary file, where you write your data as suggested by Ian and use as:

$ PIPE MONITOR < yours_file

The second way is to write a procedure which will write the the data to SYS$OUTPUT and use as this:

$ PIPE @yours_procedure | MONITOR

The contents of yours_procedure are something like this:
$ WRITE SYS$OUTPUT "MONITOR IO/SUMM=''f$cvtim("","comparison","date")'.sum"

Bojan
John Gillings
Honored Contributor

Re: Use a symbol in a DCL command procedure

You can do this with pipe, and you can do multiple input lines. You just have to turn it around the other way.

For clarity, I've defined:

$ in = "write sys$output"

So, the monitor case becomes:

$ date=f$time()-" " ! remove space
$ pipe in "monitor io/sub=''date'.sum" | monitor

For multiple lines of input, use ";" to separate commands (make sure you have a space on either side), and group lines with parentheses (). For example, assuming the symbol "pid" is set to the PID of a process of interest:

$ pipe (in "set process/index=''pid'" ; -
in "show process/channel" ; -
in "show process/lock") | -
analyze/system

The only limit is command line length.

If you do use temporary files, remember you now (V7.3-2 and higher) have F$UNIQUE() to generate names:

$ tmp="SYS$SCRATCH:"+F$UNIQUE()+".tmp;"
$ OPEN/WRITE tmp 'tmp'
$ WRITE tmp "monitor io/sum=''date'.sum"
$ CLOSE tmp
$ DEFINE/USER SYS$INPUT 'tmp'
$ MONITOR
$ DELETE 'tmp'




A crucible of informative mistakes
Jan van den Ende
Honored Contributor

Re: Use a symbol in a DCL command procedure

Thanks, John.

That IS what I meant, only, I am only just beginning with using it, and not yet totally familiar :-(
Bojan:
I simply tried what I thought looked like it,
it worked, so I posted, without really investigating more telltale variaties.

I m so sorry, won t happen again (until next time).

Cheers.

Have one on me.

Jan
Don't rust yours pelled jacker to fine doll missed aches.
Antoniov.
Honored Contributor

Re: Use a symbol in a DCL command procedure

Hello guys,
follow example works for me :-)
$ SAY="$WRITE SYS$OUTPUT" !Alias to echo
$ PIPE SAY "monit io /sum=''f$extr(0,10,f$cvtime())'.sum" | MONIT

Antonio Vigliotti

Antonio Maria Vigliotti
Ian Miller.
Honored Contributor

Re: Use a symbol in a DCL command procedure

I learn something every day here :-)

Now what is needed is for Chaim to come back and explain what he is trying to do.
____________________
Purely Personal Opinion
Chaim Budnick
Regular Advisor

Re: Use a symbol in a DCL command procedure

After some experimentation, I discovered that the following will work using a logical name and not a symbol:

$date=F$EXTRACT(0,9,F$TIME())
$define/user sum_file 'date'.sum
$monitor
monitor io/sum=sum_file/ending=18:00/int=30
$exit

I understand that this particular example doesn't really require invoking monitor and then issuing a monitor command and that I could issue the entire command as a DCL line command. However, I am looking for a way to be able to dynamically use a symbol or as I have discovered a logical for dynamic usage.

Thanks for all the replies!!

Chaim
Jan van den Ende
Honored Contributor

Re: Use a symbol in a DCL command procedure

Chaim,

"... However, I am looking for a way to be able to dynamically use a symbol ..."

As I understand this, your question is about a generic way to use to contents of a symbol to be used in the input for an image.

Then, yes, in the case where you want to use your symbol value in a (any) filename, then you can do a define logical name for that file.
The logical name definition is done in a "normal" DCL command line, ie, with normal symbol substitution.
Then, in your image data line, you use a fixed file name (that is to say, as far as DCL is concerned). So, no substitution needed. At a certain moment when your image needs the file, then RMS parses the filename to get to the file ID. And RMS knows how to handle Logical Names (without THAT, most of VMS flexibility & reliability would not exist!!).
So, as long as it is about building 'variable' filenames, DEFINE works.
For all other kinds of variable data input, you are still down to either of the above methods: the classicle "write file / execute it / delete it", or the recently available PIPE manipulations.

HTH

Cheers.

Have one on me.

Jan
Don't rust yours pelled jacker to fine doll missed aches.