copenvmsvms

how to run a c program with reading command line parameters in openvms?


I built a simple program try to print the command line parameters.

The code is below and I built an executable file (TEST.EXE).

int main(int argc, char *argv[])
{
    int i;
    printf("%s\n",argv[0]);
    for (i = 1;  i < argc;  i++)
       printf("argument %d: %s\n", i, argv[i]);
    exit (EXIT_SUCCESS);
}

I try to run the TEST.EXE and print the parameters but fail.

The result of command RUN TEST.EXE test1 test2:

%DCL-W-MAXPARM, too many parameters - reenter command with fewer parameters

What can I do to print "test1" and "test2"?


Solution

  • In addition, if you need to preserve the case of the arguments, you have to quote these arguments or enter

    $ SET PROCESS/PARSE_STYLE=EXTENDED
    

    once in the lifetime of your process and

    $ DEFINE/USER DECC$ARGV_PARSE_STYLE TRUE
    

    before running your program with a specific foreign command or by using automatic foreign commands (DCL$PATH). Otherwise all the unquoted arguments are converted to lowercase characters.

    PS: VMS has a command language, that is, you have to enter a command to run a program. By default, file names are no commands. With defining DCL$PATH you change this default behaviour.