1

On OpenVMS, it is possible to write DCL (DIGITAL Command Language) command scripts that interpret lines without the $ prompt as input to the preceding command.

For example, let's assume that we have a simple application ADD.EXE that asks for input to two questions, "Enter first value:" and "Enter second value:", and then displays the sum of these two values. Then in OpenVMS DCL it would be possible to write a command script ADD.COM like this:

$ RUN ADD.EXE
5
7

When this command script is executed (by typing @ADD.COM if I remember correctly), the output would be

12

I have tried to find a way to do the same using Windows batch scripts, but so far without success. Can it be done using batch scripts, or is there any alternative approach of accomplishing this under Windows?

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114

1 Answers1

3

There is no direct replacement of this OpenVMS feature, but the work-around is very simple:

(
echo 5
echo 7
) | add.exe

This generate a temporary file with two lines and pipe it to the input of ADD.EXE

Aacini
  • 65,180
  • 12
  • 72
  • 108
  • Fantastic! Many, many thanks @Aacini, this was just the kind of solution I was looking for! – Anders Gustafsson Mar 02 '12 at 07:54
  • @Aacini is there a way to pass the 5 with echo as you do and then return to manual user input so i can enter 7 myself or another number? I tried searching about it but i found nothing so far. On my scenario, i want to input 3 first inputs via command line like your answer and after go back to manual input for as long as the program runs. – ioannis-kokkalis May 07 '22 at 10:53