Operating System - OpenVMS
1747998 Members
4705 Online
108756 Solutions
New Discussion юеВ

Re: VMS - How to pass parameters to to an executable through DCL script

 
Sk Noorul  Hassan
Regular Advisor

VMS - How to pass parameters to to an executable through DCL script

Hi,

I have got one executable(i.e. run mc$img:xx.exe)which asks few parameter values during the execution. Now I want to automate the entire thing through a DCL script to run in a batch job every hour.

Please suggest.
15 REPLIES 15
labadie_1
Honored Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Hello

Your script shoud begin with

$! get the name of the proc file
$ self = F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))
$ subm/after="+01:00:00" 'self /que=xxx...
$ ! then run your .exe and pass the parameters
Sk Noorul  Hassan
Regular Advisor

Re: VMS - How to pass parameters to to an executable through DCL script


I mean, how to pass the parameteres to the executable inside a dcl script?
Jan van den Ende
Honored Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Hassan,

that depends on HOW the exe expects he params!

But an educated guess:
_IF_ the exe reads from standard input (SYS$INPUT), then

(beware of line wrapping!)
.
.
$ define/user SYS$INPUT SYS$COMMAND ! equate the command stream to the inputdevice for the duration of ONE image
$ run mc$img:xx
1st param
2nd param
3rd param
.
.
$ ! (any line starting with $ ends inout, and is the next DCL command)

be aware that _NO_ value substitution is done during parameter reading! If that is needed, a temporary COM file needs to be generated & @-ed.
-- Or the image must be able to take in parameters from the command line, in which case more info about the source of it is needed.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Jan van den Ende
Honored Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Hassan,

one more thing.

To get the parameters INTO the batch job, add
/PARAMS=(1st,[2nd],[3rd,[...]]]]
to the SUBMIT command.
And if you use the param-per-line mechanism I gave before, you DEFINITELY need the temporary COM file mechanism!

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Jess Goodman
Esteemed Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Jan wrote:
>$ define/user SYS$INPUT SYS$COMMAND ! equate the command stream to the inputdevice for the duration of ONE image
>$ run mc$img:xx
>1st param
>2nd param
>3rd param

Hassan,

Jan mis-spoke. Do NOT use:
$ define/user SYS$INPUT SYS$COMMAND
in a batch file. If the program is reading input from standard input (SYS$INPUT on VMS) just use the lines that come after it.

Basically lines that begin with a $ character are interpreted by DCL, but if a program is run than any lines after the $ line that runs the program (not counting a - continuation line) are passed as input to the program. The next line that begins with a $ ends the program input (if the program tries to read more lines it gets end-of-file).

It's also possible that your program will parse its parameters from a command line. If so to use a command line you can do:

$ MCR mc$img:xx.exe param1 param2 param3

which works the same interactively or in a batch job.
I have one, but it's personal.
Jon Pinkley
Honored Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

RE:"Please suggest"

Download

http://h71000.www7.hp.com/doc/731FINAL/DOCUMENTATION/PDF/OVMS_731_USERS.PDF

and at least skim chapters 13-16.

If you do programming in a compiled language, you should also grab the programming concepts documenttion:

http://h71000.www7.hp.com/doc/82FINAL/5841/aa-rnshd-te.PDF
http://h71000.www7.hp.com/doc/82final/5841/aa-pv67h-tk.PDF

If you are responsible for the system, you should know what is in the system manager's essentials:

ftp://ftp.hp.com/pub/openvms/doc/AA-PV5MJ-TK.PDF

and have the second volume on hand for reference.

http://h71000.www7.hp.com/doc/82FINAL/aa-pv5nj-tk/aa-pv5nj-tk.PDF

++++++++++++++++++++++

If you want more focused answers, please show us an example of what types of parameters the xx.exe is asking.

Normally, I think of parameters as something that is passed to the program without being prompted. For example the name of a user you want to see info about

$ show user system

That is relatively easy to do in a command procedure.

$! myshowuser.com
$! wrapper for show user
$! p1 parameter for user
$ show user 'p1' ! this substitues the first param passed to myshowuser.com
$ exit

This example is not very useful, since it adds no functionality, but it is just to demonstate a point.

Now the two following commands will do the
same thing:

$ @myshowuser system
$ show user system

However, you suggest that you really are referring to something the program is prompting the user for.

As Jan van den Ende stated, you can create an "answer file" that will be used as answers to the prompts the program generates.

However, be aware that it the questions can change based on the previous answers given, then that method will not work in the general case. It is essentially like running the program and then typing in all the answers into the typeahead buffer.

An example of what won't work: Suppose xx.exe asks for a quantity, and someone enters "j45". If the program was written with the expectation that there was a person entering the data, the appropriate action is to tell the user that "j45" isn't an acceptable answer for a quantity, and to reprompt the user for the correct answer.

If you are running from batch, you will need to make sure what is provided in the answer file is valid so that will not occur.

A harder problem is a program that asks different questions based on previous answers. If you can't predict the questions, you can't predict the correct response.

Is the mc$img:xx.exe a program written by someone in your company that you have the source code for? If so the program can be written in a way that it will accept command line parameters, which in general are much easier to deal with from DCL.

Jon
it depends
Jan van den Ende
Honored Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Jess wrote

>>>
Jan mis-spoke. Do NOT use:
$ define/user SYS$INPUT SYS$COMMAND
in a batch file.
<<<

Jeah.
My first answer was perhaps written a little bit too hastily. I SAW the "automate", but overlooked the "in a batch job".

That definition applies when input is expected from the input stream, but is to be redirected to be taken from the highest level control device (which interactively is the terminal, and in batch is the primary command file)

So sorry, it will not happen again (until next time)

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
GuentherF
Trusted Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

You have to do it via an intermediate script:

$ open/write temp temp.com
$ write temp "$ RUN myProgram"
$ write temp "param_1_value"
$ write temp "param_n_value"
$ close temp
$ @temp
$ delete temp.com;

/Guenther
Richard J Maher
Trusted Contributor

Re: VMS - How to pass parameters to to an executable through DCL script

Hi,

Also on offer: lib$get_foreign, and creating your own CLD file / DCL verbs.

Cheers Richard Maher