RE: FW: Passing large number of arguments to a program - VMS

This is a discussion on RE: FW: Passing large number of arguments to a program - VMS ; Sorry about that, Hopefully this will be better. If not let me know. Thanks, Mike ________________________________________ From: Farrell, Michael Sent: Monday, December 03, 2007 3:11 PM To: 'Info-VAX@Mvb.Saic.Com' Subject: FW: Passing large number of arguments to a program One of ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: RE: FW: Passing large number of arguments to a program

  1. RE: FW: Passing large number of arguments to a program

    Sorry about that,

    Hopefully this will be better. If not let me know.

    Thanks,

    Mike


    ________________________________________
    From: Farrell, Michael
    Sent: Monday, December 03, 2007 3:11 PM
    To: 'Info-VAX@Mvb.Saic.Com'
    Subject: FW: Passing large number of arguments to a program

    One of my programmers wrote a program that receives a huge (embarassingly huge) number of arguments. The program is run through a DCL jacket procedure that develops the arguments and calls the program.

    If the number of arguments exceeds 143, not the leading argument, (varg[0]) ,but the following leading arguments get clobbered.
    (When 144 arguments are used, arguments 1 and 2 get clobbered.)

    The program below is a stub program that shows this condition. There are 4 runs shown here. One for 143 arguments where all is fine, and one each for 144, 156, and 170 arguments where an increasing number of the leading arguments starting with argument 1 gets clobbered. (Note that if you run this you can always see that "varg[0]" is correct, always showing the exact version of the program name being executed.)

    Yes, passing a ridiculous number of arguments does bring new meaning to the expression "quick and dirty programming". And yes, there is a better way to do it, and yes, that change is being made now.

    But, what went on here? Is DCL involved in this problem? Can someone explain what could be involved?

    We are running "HP C V7.1-015 on OpenVMS Alpha V8.3". The original program was linked with a "STACK=200" command in the link options file but I'm not sure if this.

    Any insight will be greatly appreciated.

    Thanks

    Mike

    Mike Farrell
    VoltDelta Resources, LLC


    G> cc test_args.c ! Std "cc" command
    G> link test_args ! Std "link" command


    Directory $1$DKA100:[XXXX]

    TEST_ARGS.C;4 0.50KB/34KB 3-DEC-2007 10:59:41.99
    TEST_ARGS.COM;3 1KB/34KB 3-DEC-2007 11:11:17.58
    TEST_ARGS.EXE;4 3KB/34KB 3-DEC-2007 10:59:45.10
    TEST_ARGS.OBJ;4 2KB/34KB 3-DEC-2007 10:59:43.69

    Total of 4 files, 7KB/138KB
    G>




    G> ty TEST_ARGS.COM
    $! TEST_ARGS.COM
    $! -------------
    $! P1 - number of command line arguments to test
    $!
    $! This test procedure will generate requested number of command line arguments as "1 2 3 ...", and
    $! will attempt to run TEST_ARGS.EXE program while passing all those arguments. The program will attempt
    $! to simply print the list of command line arguments.
    $!
    $ if (f$type(P1) .nes. "INTEGER") then exit 4
    $!
    $ n = 0
    $ args = ""
    $ max = P1
    $LOOP:
    $ n = n + 1
    $ if (n .gt. max) then goto FINISH
    $ args = args + " ''n'"
    $ goto LOOP
    $FINISH:
    $!
    $ prog := $ $1$DKA100:[IGOR.SPB2ASC.REL_058]TEST_ARGS.EXE
    $ set verify
    $ prog 'args'
    $ set noverify
    $ exit
    G>



    G> type TEST_ARGS.c
    #include

    main(int narg, char *varg[]) {
    int n;
    for (n = 0; n < narg; n++) printf(" Arg %d: %s;", n, varg[n]);
    }
    G>




    G> @test_args 143
    $ prog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    136 137 138 139 140 141 142 143
    Arg 0: $1$dka100:[XXXX]test_args.exe;4; Arg 1: 1; Arg 2: 2; Arg 3: 3; Arg 4: 4; Arg 5: 5; Arg 6: 6; Arg 7: 7; Arg 8: 8; Arg 9: 9;
    Arg 10: 10; Arg 11: 11; Arg 12: 12; Arg 13: 13; Arg 14: 14; Arg 15: 15; Arg 16: 16; Arg 17: 17; Arg 18: 18; Arg 19: 19; Arg 20: 20; Arg 21: 21; Arg 22: 22; Arg 23: 23; Arg 24: 24; Arg 25: 25; Arg 26: 26; Arg 27: 27; Arg 28: 28; Arg 29: 29; Arg 30: 30; Arg 31: 31; Arg 32: 32; Arg 33: 33; Arg 34: 34; Arg 35: 35; Arg 36: 36; Arg 37: 37; Arg 38: 38; Arg 39: 39; Arg 40: 40; Arg 41: 41; Arg 42: 42; Arg 43: 43; Arg 44: 44; Arg 45: 45; Arg 46: 46; Arg 47: 47; Arg 48: 48; Arg 49: 49; Arg 50: 50; Arg 51: 51; Arg 52: 52; Arg 53: 53; Arg 54: 54; Arg 55: 55; Arg 56: 56; Arg 57: 57; Arg 58: 58; Arg 59: 59; Arg 60: 60; Arg 61: 61; Arg 62: 62; Arg 63: 63; Arg 64: 64; Arg 65: 65; Arg 66: 66; Arg 67: 67; Arg 68: 68; Arg 69: 69; Arg 70: 70; Arg 71: 71; Arg 72: 72; Arg 73: 73; Arg 74: 74; Arg 75: 75; Arg 76: 76; Arg 77: 77; Arg 78: 78; Arg 79: 79; Arg 80: 80; Arg 81: 81; Arg 82: 82; Arg 83: 83; Arg 84: 84; Arg 85: 85; Arg 86: 86; Arg 87: 87; Arg 88: 88; Arg 89: 89; Arg 90: 90; Arg 91: 91; Arg 92: 92; Arg 93: 93; Arg 94: 94; Arg 95: 95; Arg 96: 96; Arg 97: 97; Arg 98: 98; Arg 99: 99; Arg 100: 100; Arg 101: 101; Arg 102: 102; Arg 103: 103; Arg 104: 104; Arg 105: 105; Arg 106: 106; Arg 107: 107; Arg 108: 108; Arg 109: 109; Arg 110: 110; Arg 111: 111; Arg 112: 112; Arg 113: 113; Arg 114: 114; Arg 115: 115; Arg 116: 116; Arg 117: 117; Arg 118: 118; Arg 119: 119; Arg 120: 120; Arg 121: 121; Arg 122: 122; Arg 123: 123; Arg 124: 124; Arg 125: 125; Arg 126: 126; Arg 127: 127; Arg 128: 128; Arg 129: 129; Arg 130: 130; Arg 131: 131; Arg 132: 132; Arg 133: 133; Arg 134: 134; Arg 135: 135; Arg 136: 136; Arg 137: 137; Arg 138: 138; Arg 139: 139; Arg 140: 140; Arg 141: 141; Arg 142: 142; Arg 143: 143;
    $ set noverify
    G>
    G>
    G> @test_args 144
    $ prog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    Arg 0: $1$dka100:[XXXX]test_args.exe;4; Arg 1: D; Arg 2: ; Arg 3: 3; Arg 4: 4; Arg 5: 5; Arg 6: 6; Arg 7: 7; Arg 8: 8; Arg 9: 9;
    Arg 10: 10; Arg 11: 11; Arg 12: 12; Arg 13: 13; Arg 14: 14; Arg 15: 15; Arg 16: 16; Arg 17: 17; Arg 18: 18; Arg 19: 19; Arg 20: 20; Arg 21: 21; Arg 22: 22; Arg 23: 23; Arg 24: 24; Arg 25: 25; Arg 26: 26; Arg 27: 27; Arg 28: 28; Arg 29: 29; Arg 30: 30; Arg 31: 31; Arg 32: 32; Arg 33: 33; Arg 34: 34; Arg 35: 35; Arg 36: 36; Arg 37: 37; Arg 38: 38; Arg 39: 39; Arg 40: 40; Arg 41: 41; Arg 42: 42; Arg 43: 43; Arg 44: 44; Arg 45: 45; Arg 46: 46; Arg 47: 47; Arg 48: 48; Arg 49: 49; Arg 50: 50; Arg 51: 51; Arg 52: 52; Arg 53: 53; Arg 54: 54; Arg 55: 55; Arg 56: 56; Arg 57: 57; Arg 58: 58; Arg 59: 59; Arg 60: 60; Arg 61: 61; Arg 62: 62; Arg 63: 63; Arg 64: 64; Arg 65: 65; Arg 66: 66; Arg 67: 67; Arg 68: 68; Arg 69: 69; Arg 70: 70; Arg 71: 71; Arg 72: 72; Arg 73: 73; Arg 74: 74; Arg 75: 75; Arg 76: 76; Arg 77: 77; Arg 78: 78; Arg 79: 79; Arg 80: 80; Arg 81: 81; Arg 82: 82; Arg 83: 83; Arg 84: 84; Arg 85: 85; Arg 86: 86; Arg 87: 87; Arg 88: 88; Arg 89: 89; Arg 90: 90; Arg 91: 91; Arg 92: 92; Arg 93: 93; Arg 94: 94; Arg 95: 95; Arg 96: 96; Arg 97: 97; Arg 98: 98; Arg 99: 99; Arg 100: 100; Arg 101: 101; Arg 102: 102; Arg 103: 103; Arg 104: 104; Arg 105: 105; Arg 106: 106; Arg 107: 107; Arg 108: 108; Arg 109: 109; Arg 110: 110; Arg 111: 111; Arg 112: 112; Arg 113: 113; Arg 114: 114; Arg 115: 115; Arg 116: 116; Arg 117: 117; Arg 118: 118; Arg 119: 119; Arg 120: 120; Arg 121: 121; Arg 122: 122; Arg 123: 123; Arg 124: 124; Arg 125: 125; Arg 126: 126; Arg 127: 127; Arg 128: 128; Arg 129: 129; Arg 130: 130; Arg 131: 131; Arg 132: 132; Arg 133: 133; Arg 134: 134; Arg 135: 135; Arg 136: 136; Arg 137: 137; Arg 138: 138; Arg 139: 139; Arg 140: 140; Arg 141: 141; Arg 142: 142; Arg 143: 143; Arg 144: 144;
    $ set noverify
    G>
    G>
    G> @test_args 156
    $ prog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
    Arg 0: $1$dka100:[XXXX]test_args.exe;4; Arg 1: D; Arg 2: ; Arg 3: D; Arg 4: ; Arg 5: D; Arg 6: ; Arg 7: D; Arg 8: ; Arg 9: D; Arg 13: ;
    Arg 14: ; Arg 15: D; Arg 16: D; Arg 17: ; Arg 18: ; Arg 19: D;
    Arg 20: D; Arg 21: ; Arg 22: 22; Arg 23: 23; Arg 24: 24; Arg 25: 25; Arg 26: 26; Arg 27: 27; Arg 28: 28; Arg 29: 29; Arg 30: 30; Arg 31: 31; Arg 32: 32; Arg 33: 33; Arg 34: 34; Arg 35: 35; Arg 36: 36; Arg 37: 37; Arg 38: 38; Arg 39: 39; Arg 40: 40; Arg 41: 41; Arg 42: 42; Arg 43: 43; Arg 44: 44; Arg 45: 45; Arg 46: 46; Arg 47: 47; Arg 48: 48; Arg 49: 49; Arg 50: 50; Arg 51: 51; Arg 52: 52; Arg 53: 53; Arg 54: 54; Arg 55: 55; Arg 56: 56; Arg 57: 57; Arg 58: 58; Arg 59: 59; Arg 60: 60; Arg 61: 61; Arg 62: 62; Arg 63: 63; Arg 64: 64; Arg 65: 65; Arg 66: 66; Arg 67: 67; Arg 68: 68; Arg 69: 69; Arg 70: 70; Arg 71: 71; Arg 72: 72; Arg 73: 73; Arg 74: 74; Arg 75: 75; Arg 76: 76; Arg 77: 77; Arg 78: 78; Arg 79: 79; Arg 80: 80; Arg 81: 81; Arg 82: 82; Arg 83: 83; Arg 84: 84; Arg 85: 85; Arg 86: 86; Arg 87: 87; Arg 88: 88; Arg 89: 89; Arg 90: 90; Arg 91: 91; Arg 92: 92; Arg 93: 93; Arg 94: 94; Arg 95: 95; Arg 96: 96; Arg 97: 97; Arg 98: 98; Arg 99: 99; Arg 100: 100; Arg 101: 101; Arg 102: 102;
    Arg 103: 103; Arg 104: 104; Arg 105: 105; Arg 106: 106; Arg 107: 107; Arg 108: 108; Arg 109: 109; Arg 110: 110; Arg 111: 111; Arg 112: 112; Arg 113: 113; Arg 114: 114; Arg 115: 115; Arg 116: 116; Arg 117: 117; Arg 118: 118; Arg 119: 119; Arg 120: 120; Arg 121: 121; Arg 122: 122; Arg 123: 123; Arg 124: 124; Arg 125: 125; Arg 126: 126; Arg 127: 127; Arg 128: 128; Arg 129: 129; Arg 130: 130; Arg 131: 131; Arg 132: 132; Arg 133: 133; Arg 134: 134; Arg 135: 135; Arg 136: 136; Arg 137: 137; Arg 138: 138; Arg 139: 139; Arg 140: 140; Arg 141: 141; Arg 142: 142; Arg 143: 143; Arg 144: 144; Arg 145: 145; Arg 146: 146; Arg 147: 147; Arg 148: 148; Arg 149: 149; Arg 150: 150; Arg 151: 151; Arg 152: 152; Arg 153: 153; Arg 154: 154; Arg 155: 155; Arg 156: 156;
    $ set noverify
    G>
    G>
    G> @test_args 170
    $ prog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
    Arg 0: $1$dka100:[XXXX]test_args.exe;4; Arg 1: D; Arg 2: ; Arg 3: D; Arg 4: ; Arg 5: D; Arg 6: ; Arg 7: D; Arg 8: ; Arg 9: D; Arg 13: ; Arg 14: ; Arg 15: D; Arg 16: D; Arg 17: ; Arg 18: ; Arg 19: D;
    Arg 20: D; Arg 21: ; Arg 22: ; Arg 23: D; Arg 24: D; Arg 25: ;
    Arg 26: ; Arg 27: D; Arg 28: D; Arg 29: ; Arg 30: ; Arg 31: D; Arg 32: D; Arg 33: ; Arg 34: ; Arg 35: D; Arg 36: D; Arg 37: ; Arg 38: ; Arg 39: D; Arg 40: 40; Arg 41: 41; Arg 42: 42; Arg 43: 43; Arg 44: 44; Arg 45: 45; Arg 46: 46; Arg 47: 47; Arg 48: 48; Arg 49: 49; Arg 50: 50; Arg 51: 51; Arg 52: 52; Arg 53: 53; Arg 54: 54; Arg 55: 55; Arg 56: 56; Arg 57: 57; Arg 58: 58; Arg 59: 59; Arg 60: 60; Arg 61: 61; Arg 62: 62; Arg 63: 63; Arg 64: 64; Arg 65: 65; Arg 66: 66; Arg 67: 67; Arg 68: 68;
    Arg 69: 69; Arg 70: 70; Arg 71: 71; Arg 72: 72; Arg 73: 73;
    Arg 74: 74; Arg 75: 75; Arg 76: 76; Arg 77: 77; Arg 78: 78; Arg 79: 79; Arg 80: 80; Arg 81: 81; Arg 82: 82; Arg 83: 83; Arg 84: 84; Arg 85: 85; Arg 86: 86; Arg 87: 87; Arg 88: 88; Arg 89: 89; Arg 90: 90; Arg 91: 91; Arg 92: 92; Arg 93: 93; Arg 94: 94; Arg 95: 95; Arg 96: 96; Arg 97: 97; Arg 98: 98; Arg 99: 99; Arg 100: 100; Arg 101: 101; Arg 102: 102;
    Arg 103: 103; Arg 104: 104; Arg 105: 105; Arg 106: 106; Arg 107: 107; Arg 108: 108; Arg 109: 109; Arg 110: 110; Arg 111: 111; Arg 112: 112; Arg 113: 113; Arg 114: 114; Arg 115: 115; Arg 116: 116; Arg 117: 117; Arg 118: 118; Arg 119: 119; Arg 120: 120; Arg 121: 121; Arg 122: 122; Arg 123: 123; Arg 124: 124; Arg 125: 125; Arg 126: 126; Arg 127: 127; Arg 128: 128; Arg 129: 129; Arg 130: 130; Arg 131: 131; Arg 132: 132; Arg 133: 133; Arg 134: 134; Arg 135: 135; Arg 136: 136; Arg 137: 137; Arg 138: 138; Arg 139: 139; Arg 140: 140; Arg 141: 141; Arg 142: 142; Arg 143: 143; Arg 144: 144; Arg 145: 145; Arg 146: 146; Arg 147: 147; Arg 148: 148; Arg 149: 149; Arg 150: 150; Arg 151: 151; Arg 152: 152; Arg 153: 153; Arg 154: 154; Arg 155: 155; Arg 156: 156; Arg 157: 157; Arg 158: 158; Arg 159: 159; Arg 160: 160; Arg 161: 161; Arg 162: 162; Arg 163: 163; Arg 164: 164; Arg 165: 165; Arg 166: 166; Arg 167: 167; Arg 168: 168; Arg 169: 169; Arg 170: 170;
    $ set noverify
    G>
    G>

    -----Original Message-----
    From: VAXman- @SendSpamHere.ORG [mailto:VAXman- @SendSpamHere.ORG]
    Sent: Monday, December 03, 2007 3:51 PM
    To: Info-VAX@Mvb.Saic.Com
    Subject: Re: FW: Passing large number of arguments to a program

    In article <4754650b$0$7446$88260bb3@news.teranews.com>, Ken Robinson writes:
    >
    >
    >sol gongola wrote in
    >news:2OZ4j.235$Id1.109@newsfe10.lga:
    >
    >> I am still on vms 7.2-1.
    >> vms 8.3 allows more than p1...p8?

    >
    >DCL only allows 8 arguments, the OP is passing the arguments to a C
    >program. What the OP is probably running into is the maximum lenght of a
    >DCL line,



    The OP didn't bother to post his code in plain text making it virtually
    impossible for me to bother to decipher it. 2000+ lines of unreadable
    code.

    --
    VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)COM

    "Well my son, life is like a beanstalk, isn't it?"

    http://tmesis.com/drat.html

  2. Re: FW: Passing large number of arguments to a program

    Suggestion:

    Instead of running your program, get the arguments into a single string
    and do a F$LENGTH of it.

    aka:

    chocolate:= "$myprogram.exe"

    instead of doing:
    $chocolate 1 2 3 4 5 ... 143
    do

    $vanilla = "1 2 3 4 5 6 ... 143"
    $write sys$output "Length of argument list is "''f$length(vanilla)'"

    You could also include in that length the actual command.
    (either "chocolate" or "$myprogram.exe")


  3. Re: FW: Passing large number of arguments to a program

    Another (third ?) paramater passing method
    I often use (at least by COM files calling other
    COM files) is to pass the paramaters by logicals
    or symbols. No practical limitations.

    Jan-Erik.

  4. Re: FW: Passing large number of arguments to a program

    "Farrell, Michael" wrote:
    >
    > Sorry about that,
    >
    > Hopefully this will be better. If not let me know.


    Not. Turn off MIME, and make sure to set your news program to post as
    plain text only only.

    > Thanks,
    >
    > Mike
    >
    > ________________________________________
    > From: Farrell, Michael
    > Sent: Monday, December 03, 2007 3:11 PM
    > To: 'Info-VAX@Mvb.Saic.Com'
    > Subject: FW: Passing large number of arguments to a program
    >
    > One of my programmers wrote a program that receives a huge

    (embarassingly huge) number of arguments. The program is run through a
    DCL jacket procedure that develops the arguments and calls the program.
    >
    > If the number of arguments exceeds 143, not the leading argument,

    (varg[0]) ,but the following leading arguments get clobbered.
    > (When 144 arguments are used, arguments 1 and 2 get clobbered.)
    >
    > The program below is a stub program that shows this condition. There

    are 4 runs shown here. One for 143 arguments where all is fine, and
    one
    each for 144, 156, and 170 arguments where an increasing number of the
    leading arguments starting with argument 1 gets clobbered. (Note that
    if
    you run this you can always see that "varg[0]" is correct, always
    showing
    the exact version of the program name being executed.)
    >
    > Yes, passing a ridiculous number of arguments does bring new meaning to

    the expression "quick and dirty programming". And yes, there is a
    better
    way to do it, and yes, that change is being made now.
    >
    > But, what went on here? Is DCL involved in this problem? Can someone

    explain what could be involved?
    >
    > We are running "HP C V7.1-015 on OpenVMS Alpha V8.3". The original

    program was linked with a "STACK=200" command in the link options file
    but I'm not sure if this.

    (Long lines manually broken into readable form.)

    Have you tried:

    $ prog "''args'"

    ....? That may return a single argument of space-separated elements.
    Dunno if your code can handle that.

    Please consider redesigning the program to accept a more manageable
    argument list, or read them in from a file or some other approach.

    This may be a lot of work to discover that the original approach was a
    candidate for improvement.

    My $0.02...

    David J Dachtera
    DJE Systems

+ Reply to Thread