home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / upc12b22.zip / su.cmd < prev    next >
OS/2 REXX Batch file  |  1993-05-09  |  5KB  |  116 lines

  1. /*--------------------------------------------------------------------*/
  2. /*          Program:    su.cmd            3 May 1993                  */
  3. /*          Author:     Andrew H. Derbyshire                          */
  4. /*          Address:    Kendra Electronic Wonderworks                 */
  5. /*                      P.O. Box 132                                  */
  6. /*                      Arlington, MA 02174                           */
  7. /*          Internet:   help@kew.com                                  */
  8. /*          Language:   OS/2 2.0 REXX                                 */
  9. /*          Function:   Report mail waiting for users                 */
  10. /*        Parameters:   None                                          */
  11. /*       Environment:   Assumes OS/2 Environment variable             */
  12. /*                      UUPCSYSRC has been set to name of UUPC/       */
  13. /*                      extended system configuration file, and       */
  14. /*                      TEMP variable been set if not defined         */
  15. /*                      in UUPC/extended.                             */
  16. /*--------------------------------------------------------------------*/
  17.  
  18. /*--------------------------------------------------------------------*/
  19. /*       Copyright 1990-1992 By Kendra Electronic Wonderworks;        */
  20. /*       may be distributed freely if original documentation and      */
  21. /*       source are included, and credit is given to the authors.     */
  22. /*       For additional instructions, see README.PRN in UUPC/         */
  23. /*       extended documentation archive.                              */
  24. /*--------------------------------------------------------------------*/
  25.  
  26. /*--------------------------------------------------------------------*/
  27. /*       REXX function to change effective user id and optionally     */
  28. /*       run a command as that user.                                  */
  29. /*--------------------------------------------------------------------*/
  30.  
  31. /*
  32.  *       $Id: SU.CMD 1.3 1993/05/09 03:51:26 ahd Exp $
  33.  *
  34.  *       $Log: SU.CMD $
  35.  *      Revision 1.3  1993/05/09  03:51:26  ahd
  36.  *      Don't uppercase the input
  37.  *
  38.  *      Revision 1.2  1993/05/04  00:25:58  ahd
  39.  *      COnvert to REXX
  40.  *
  41.  *
  42.  */
  43.  
  44. '@echo off'
  45. signal on novalue
  46. parse source stuff
  47. Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  48. Call 'SysLoadFuncs'
  49. parse arg who what;
  50. if words(who) = 0 then
  51. do;
  52.    say 'SU.CMD Copyright 1989-1993 Kendra Electronic Wonderworks';
  53.    say 'No user specified to SU to';
  54.    exit 1;
  55. end;
  56. who = strip(who);
  57.  
  58. confdir = getuupc("CONFDIR")
  59. if confdir == '' then
  60. do
  61.    say 'No configuration directory defined, cannot continue'
  62.    exit 98
  63. end
  64.  
  65. uupcusrc = confDir || '\' || who || '.RC'
  66. who      = getuupc("MAILBOX",who,uupcusrc)
  67. if \ exist( uupcusrc ) then
  68. do;
  69.    say uupcusrc 'does not exist!  Please verify' who 'is a valid user'
  70.    exit 97;
  71. end;
  72.  
  73. call SetLocal;
  74. uupcusrc = value( 'UUPCUSRRC',uupcusrc,'OS2ENVIRONMENT');
  75.  
  76. if words(what) == 0 then
  77. do;
  78.    prompt = 'Enter EXIT to logout from' who || '$_' || ,
  79.             value( 'PROMPT',,'OS2ENVIRONMENT');       /* Make new prompt */
  80.    prompt = value( 'PROMPT',prompt,'OS2ENVIRONMENT'); /* Set new prompt  */
  81.    value( 'COMSPEC',,'OS2ENVIRONMENT');
  82.    prompt = value( 'PROMPT',prompt,'OS2ENVIRONMENT'); /* Restore prompt   */
  83. end;
  84. else
  85.    what;
  86.  
  87. uupcusrc = value( 'UUPCUSRRC',uupcusrc,'OS2ENVIRONMENT');
  88.                                  /* Restore original value           */
  89. call endlocal;
  90. exit rc;
  91.  
  92. /*--------------------------------------------------------------------*/
  93. /*    e x i s t                                                       */
  94. /*                                                                    */
  95. /*    Report whether or not a file exists                             */
  96. /*--------------------------------------------------------------------*/
  97. exist: procedure
  98. parse arg file
  99. xrc = SysFileTree(file, 'data.','F')
  100. if data.0 == 0 then
  101.    return 0
  102. else
  103.    return 1
  104.  
  105. /*--------------------------------------------------------------------*/
  106. /*    n o v a l u e                                                   */
  107. /*                                                                    */
  108. /*    Trap for uninitialized variables                                */
  109. /*--------------------------------------------------------------------*/
  110.  
  111. novalue:
  112. trace n
  113. signal off novalue;           /* Avoid nasty recursion         */
  114. say 'Uninitialized variable in line' sigl || ':';
  115. say sourceline( sigl );
  116.