Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

openvms

vms

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"?

like image 224
Y.C. Avatar asked Dec 06 '22 18:12

Y.C.


2 Answers

The RUN command doesn't support any command line arguments. Define a foreign command and use that instead. From David Mathog's beginner FAQ:

How do I start a program?

  • Method 2: Use the RUN command:

    $ run program_nameNo command line arguments allowed

  • Method 3: Define a foreign command for it, then run it. In the following example where is a logical name equivalent to the location of the program.

    $ new_command :== $where:program_name $ new_command [command line arguments]

like image 78
a3f Avatar answered Jan 18 '23 15:01

a3f


Defining a foreign command as per 'a3f' is the 'proper' way to do it albeit somewhat tedious and 2-stepped.

You may also want to try the MCR 'trick'. MCR being short for the Monitor Command Routine from the 40+ year old PDPD-11 Operating System RSX.

Now MCR defaults to look for program in SYS$SYSTEM, so you do have to specify the current location:

$ MCR dev:[dir]TEST this is a test.

There is also a 1-1/2 step approach using DCL$PATH. This works mostly like the Unix and Windows path, providing places to look for DCL scripts or programs if an unknown command is entered.

For example

$ DEFINE DCL$PATH SYS$DISK:[],SYS$LOGIN:,SYS$SYSTEM:

Now just type : TEST this.

Hein

like image 31
Hein Avatar answered Jan 18 '23 15:01

Hein