home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / vms / 13994 < prev    next >
Encoding:
Internet Message Format  |  1992-08-23  |  1.6 KB

  1. Path: sparky!uunet!cs.utexas.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!EQL.CALTECH.EDU!rankin
  2. From: rankin@EQL.CALTECH.EDU (Pat Rankin)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: LIB$SPAWN
  5. Message-ID: <920822020019.24e01554@EQL.Caltech.Edu>
  6. Date: 22 Aug 92 09:01:17 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Organization: The Internet
  9. Lines: 30
  10.  
  11. alex khalil <no return address> writes:
  12. > Would a kind soul explain to me why in the following code, a subprocess
  13. > is spawned, a sort is started, but the names of the input and output
  14. > files are not passed. Sort comes back to you and asks for them.
  15. ...
  16.    DCL_command = "sort data.PCSA data.sort";
  17.    spawn( DCL_command  );
  18. ...
  19. > void spawn( char *DCL_command  )
  20. > {
  21. >    int status;
  22. >    $DESCRIPTOR( command , DCL_command  );
  23. >    if ((( status=LIB$SPAWN( &command )) & 1 ) != 1 )  LIB$STOP( status );
  24. > }
  25.  
  26.      Because the $DESCRIPTOR macro uses C's sizeof operator to fill in
  27. the length field.  `sizeof DCL_command' is the same as `sizeof(char *)',
  28. which is always 4 on the VAX.  So the command you're actually passing
  29. to LIB$SPAWN is just "sort" regardless of what the printf() reported.
  30. Sticking `LIB$PUT_OUTPUT(&command);' into your spawn() routine would
  31. have shown that.
  32.  
  33.      You need to add
  34.        `command.dsc$w_length = strlen(command.dsc$a_pointer);'
  35. between the $DESCRIPTOR macro and the call to LIB$SPAWN.  Since you're
  36. not using any of LIB$SPAWN's optional arguments, you might as well use
  37. `status = system(DCL_command);' and skip the VMS-specific stuff.
  38.  
  39.                 Pat Rankin, rankin@eql.caltech.edu
  40.  
  41.