home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / vms / 17736 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  8.9 KB

  1. Path: sparky!uunet!ogicse!uwm.edu!spool.mu.edu!news.nd.edu!bsu-cs!bsu-ucs.uucp!00prneubauer
  2. From: 00prneubauer@leo.bsuvc.bsu.edu (Paul Neubauer)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: TPU -- get process info question
  5. Message-ID: <1992Nov10.115144.11709@bsu-ucs>
  6. Date: 10 Nov 92 16:51:44 GMT
  7. Article-I.D.: bsu-ucs.1992Nov10.115144.11709
  8. References: <Bx91zz.9wF@nocusuhs.nnmc.navy.mil> <1992Nov5.104950.1@slacvx.slac.stanford.edu>
  9. Distribution: usa
  10. Organization: Ball State U.
  11. Lines: 173
  12.  
  13. In article <1992Nov5.104950.1@slacvx.slac.stanford.edu>, 
  14.  Ken Fairfield, fairfield@slacvx.slac.stanford.edu writes:
  15. > In article <Bx91zz.9wF@nocusuhs.nnmc.navy.mil>, 
  16. >  yoshikami@usuhsb.ucc.usuhs.nnmc.navy.mil (UCC MR. D M YOSHIKAMI) writes:
  17. >> 
  18. >> Quick TPU question.  We have a small tpu script in which it would be nice to
  19. >> have the USERNAME (right now we have to enter it by hand).  Is there a way to
  20. >> do the equivalent of GETJPI("","USERNAME") without going through a lot of
  21. >> trouble?  I was looking for a function (maybe I overlooked something in the 
  22. >> manual?), and thought I'd eventually have to spin off a subprocess to look it 
  23. >> up, which seems to be an awful lot of work for so simple a function.
  24. >     There is no TPU built-in function to do what you want.  
  25. >     OTOH, you can write a TPU_CALLUSER program (shareable image), in the
  26. > language of your choice, which in turn calls, e.g. LIB$GETJPI, and returns
  27. > the information you wanted to your TPU procedure.  Look in the VAXTPU manual 
  28. > (page 7-39/7-42 in the VMS V5.2 docs) for the description of CALL_USER.  It
  29. > contains an example VAX BASIC (really! ;-).  
  30. >     The only tricky part of all this is that the string _returned_ by your 
  31. > procedure must be by DYNAMIC string descriptor (which is why the example is
  32. > in BASIC).  In Fortran, which uses static descriptors, you'll need to call
  33. > STR$GET1_DX and STR$COPY_DX in order to "get and fill" a dynamic string.
  34. > From C, you should be able to use the DESCRIP.H macros to handle the
  35. > descriptors.  Someone else will have to comment on PASCAL...
  36.  
  37. No problem, Ken.  :-)  Here's a Pascal program that does what he wants
  38. (and then some :-).  The internal docs show how to build and use it.
  39.  
  40.     Paul
  41. -- 
  42. Paul Neubauer   00prneubauer@leo.bsuvc.bsu.edu  00prneubauer@bsuvax1.BITNET
  43.                 00prneubauer@bsu-ucs.UUCP       neubauer@bsu-cs.UUCP
  44.  
  45. ---------------  Cut here ----------------
  46. (******************************************************************************)
  47. (* FACILITY:                                                                  *)
  48. (*      EVE extensions                                                        *)
  49. (*                                                                            *)
  50. (* ABSTRACT:                                                                  *)
  51. (*      This is a module of functions to be called by means of the            *)
  52. (*      TPU built-in CALL_USER.                                               *)
  53. (*                                                                            *)
  54. (* ENVIRONMENT:                                                               *)
  55. (*      VAX/VMS, version 5.0 or higher (This version built with 5.5)          *)
  56. (*                                                                            *)
  57. (* LANGUAGE: VAX Pascal, version 3.8 or higher (This version built with 4.2)  *)
  58. (*                                                                            *)
  59. (* AUXILIARY FILE(S) REQUIRED:                                                *)
  60. (*      None.  The shareable image created from this source file is           *)
  61. (*      itself an auxiliary file to the EVE section file.                     *)
  62. (*      The logical name TPU$CALLUSER must be defined to point to             *)
  63. (*      the shareable image.                                                  *)
  64. (*                                                                            *)
  65. (* BUILD PROCEDURE:                                                           *)
  66. (*      $ pascal calluser                                                     *)
  67. (*      $ link/share calluser, sys$input/opt                                  *)
  68. (*      universal=tpu$calluser                                                *)
  69. (*      ^Z                                                                    *)
  70. (*      $ define tpu$calluser <device>:[<directory>]calluser.exe              *)
  71. (*                                                                            *)
  72. (* USAGE EXAMPLES:                                                            *)
  73. (*      section := call_user (1, "tpu$section") !translates log name          *)
  74. (*      value   := call_user (2, "symbol_name") !translates symbol to string  *)
  75. (*      user    := call_user (3, ""));          !username to variable "user"  *)
  76. (*      message   (call_user (4, ""));          !displays process name        *)
  77. (*                                                                            *)
  78. (* AUTHOR:  Paul Neubauer                                                     *)
  79. (*                                                                            *)
  80. (* DATE:  8-Jul-1992                                                          *)
  81. (*                                                                            *)
  82. (* VERSION:  2.0                                                              *)
  83. (*                                                                            *)
  84. (* MODIFIED BY: PRN, 10-NOV-1992                                              *)
  85. (*                                                                            *)
  86. (******************************************************************************)
  87. [INHERIT ('sys$library:starlet',
  88.           'sys$library:pascal$lib_routines',
  89.           'sys$library:pascal$str_routines')]
  90. MODULE calluser;
  91. CONST
  92.     maxlen     = 200;
  93. TYPE
  94.     varstring  = varying [maxlen] of char;
  95.     fixstring  = packed array [1..maxlen] of char;
  96.     $uword     = [word] 0..65535;               {repeated from STARLET.PAS}
  97.     $byte      = [byte] -128..127;              {because hidden there}
  98.     $ubyte     = [byte] 0..255;
  99.  
  100. { Translate a DCL logical name and return the translation as a string.
  101.   Return null string if no translation found.  
  102. }
  103. PROCEDURE translate_lnm (    input_string  : varstring ; 
  104.                          VAR output_string : varstring );
  105. VAR
  106.     return_status    : integer;
  107.     trnlnm_item_list :  RECORD
  108.                         buffer_length : $uword;
  109.                         item_code     : $uword;
  110.                         buffer_address: integer;
  111.                         return_length : integer;
  112.                         end_of_list   : integer;
  113.                         END;
  114. BEGIN
  115.     output_string := '';
  116.     with trnlnm_item_list do                {build the item list}
  117.         BEGIN
  118.         buffer_length   := size(output_string.body);
  119.         item_code       := lnm$_string;
  120.         buffer_address  := iaddress(output_string.body);
  121.         return_length   := iaddress(output_string.length);
  122.         end_of_list     := 0;
  123.         END; {with}
  124.     return_status := $trnlnm(
  125.         attr    := lnm$m_case_blind,
  126.         tabnam  := 'LNM$DCL_LOGICAL',
  127.         lognam  := input_string,
  128.         itmlst  := trnlnm_item_list);
  129. END; {procedure translate_lnm}
  130.  
  131. { Get Job/Process Information and return as string.
  132. }
  133. PROCEDURE jpi ( VAR the_info:varstring ; item:$UWORD );
  134. TYPE
  135.     sys$itmlst = RECORD
  136.                  buffer_length  : $uword;
  137.                  item_code      : $uword;
  138.                  buffer_address : unsigned;
  139.                  return_address : integer;
  140.                  terminator     : unsigned;
  141.                  END;
  142. VAR
  143.     item_list : sys$itmlst;
  144.     outstring : varstring;
  145.     how_many  : $uword;
  146.     status    : unsigned;
  147. BEGIN
  148. the_info := '';
  149. item_list.buffer_length  := size(the_info.body);
  150. item_list.item_code      := item;
  151. item_list.buffer_address := iaddress(the_info.body);
  152. item_list.return_address := iaddress(the_info.length);
  153. item_list.terminator     := 0;
  154. status := $getjpiw (itmlst := item_list);
  155. END; {procedure jpi}
  156.  
  157. [global] FUNCTION tpu$calluser ( dispatch_no : integer   ; 
  158.                                  VAR input   : dsc1$type ;
  159.                                  VAR output  : dsc1$type ) : integer;
  160. VAR
  161.     the_status : unsigned;
  162.     instring   : varstring;
  163.     outstring  : varstring;
  164. BEGIN
  165.     {First change the input string to a form we can use directly.}
  166.     the_status  := str$copy_dx ( %DESCR instring , %REF input );
  167.     outstring   := '';
  168.     CASE dispatch_no OF
  169.         1       : translate_lnm ( instring , outstring );
  170.         2       : lib$get_symbol ( %REF input , %DESCR outstring );
  171.         3       : jpi ( outstring , jpi$_username ); 
  172.         4       : jpi ( outstring , jpi$_prcnam ); 
  173.         otherwise outstring := ''
  174.         END; {case}
  175.     IF (outstring = '') THEN
  176.         tpu$calluser := ss$_badparam
  177.     ELSE
  178.         tpu$calluser := ss$_normal;
  179.     the_status  := str$copy_dx ( %REF output , outstring );
  180. END; {function tpu$calluser}
  181.  
  182. END. {module calluser}
  183.