home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / db22re.zip / SHOWAUTH.CMD < prev    next >
OS/2 REXX Batch file  |  1993-03-09  |  4KB  |  129 lines

  1. /*
  2.  ┌──────────────────────────────────────────────────────────────────┐
  3.  │  Name       : showauth.cmd                                       │
  4.  │  Purpose    : show auth of logged-on user                        │
  5.  │  Platform   : DB2/2                                              │
  6.  │  Author     : Jeff Fisher                                        │
  7.  │               IBM Toronto Development Lab                        │
  8.  │  Disclaimer : This "sample" code is for demonstrations only, no  │
  9.  │               warrenties are made or implied as to correct       │
  10.  │               function. You should carefully test this code in   │
  11.  │               your own environment before using it.              │
  12.  │                                                                  │
  13.  └──────────────────────────────────────────────────────────────────┘
  14. */
  15.  
  16.  
  17. Status:
  18.     call SetColor
  19.     address cmd '@echo off'
  20.     call SQLDBS 'OPEN DATABASE DIRECTORY ON D USING :scanvar'
  21.     if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  22.  
  23.     scanid = scanvar.1
  24.  
  25.     say
  26.     say c.yellow
  27.     say 'There are' scanvar.2 'databases on drive D:'
  28.     say c.itcyan
  29.  
  30.     do i=1 to scanvar.2
  31.         call SQLDBS 'GET DATABASE DIRECTORY ENTRY :scanvar.1 USING :entry'
  32.         if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  33.  
  34.         call Start_Using entry.1
  35.  
  36.         call SQLDBS 'GET AUTHORIZATIONS :cvar'
  37.         if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  38.         call Stop_Using
  39.  
  40.         if cvar.1 = '1' then cvar1 = 'yes'
  41.           else cvar1 = 'no '
  42.         if cvar.2 = '1' then cvar2 = 'yes'
  43.           else cvar2 = 'no '
  44.         if cvar.3 = '1' then cvar3 = 'yes'
  45.           else cvar3 = 'no '
  46.         if cvar.4 = '1' then cvar4 = 'yes'
  47.           else cvar4 = 'no '
  48.         if cvar.5 = '1' then cvar5 = 'yes'
  49.           else cvar5 = 'no '
  50.         if cvar.6 = '1' then cvar6 = 'yes'
  51.           else cvar6 = 'no '
  52.         if cvar.7 = '1' then cvar7 = 'yes'
  53.           else cvar7 = 'no '
  54.         if cvar.8 = '1' then cvar8 = 'yes'
  55.           else cvar8 = 'no '
  56.         if cvar.9 = '1' then cvar9 = 'yes'
  57.           else cvar9 = 'no '
  58.         if cvar.10 = '1' then cvar10 = 'yes'
  59.           else cvar10 = 'no '
  60.  
  61.         address cmd 'CLS'
  62.         say c.itgreen
  63.         say '  ------------------------------------------'
  64.         say c.yellow
  65.         say '  Your authorizations for Database:' entry.1
  66.         say c.itcyan
  67.         say '             Direct      Indirect'
  68.         say c.green
  69.         say '    SYSADM     'CVAR1'         'CVAR6
  70.         say '    DBADM      'CVAR2'         'CVAR7
  71.         say '    CREATETAB  'CVAR3'         'CVAR8
  72.         say '    BINDADD    'CVAR4'         'CVAR9
  73.         say '    CONNECT    'CVAR5'         'CVAR10
  74.         say c.itgreen
  75.         say '  ------------------------------------------'
  76.         say c.normal
  77.         pause
  78.  
  79.     end
  80.  
  81.     call SQLDBS 'CLOSE DATABASE DIRECTORY :scanid'
  82.     if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  83.  
  84. EndProg:
  85.     exit
  86.  
  87. Start_Using:
  88.     arg DBNAME
  89.     call SQLEXEC 'CONNECT TO' DBNAME 'IN SHARED MODE'
  90.     if SQLCA.SQLCODE \=0 then signal ErrorSQL
  91.     return
  92.  
  93. Stop_Using:
  94.     arg DBNAME
  95.     call SQLEXEC 'CONNECT RESET'
  96.     if SQLCA.SQLCODE \=0 then signal ErrorSQL
  97.     return
  98.  
  99. ErrorSQL:
  100.     call beep 220,1000
  101.     say c.itred
  102.     say '        >>>  SQL has returned a fatal condition code'
  103.     say '             abending step = ' step
  104.     say '             SQLCODE       = ' SQLCA.SQLCODE
  105.     say '             MSG           = ' SQLMSG
  106.     say
  107.     call SQLDBS 'CLOSE DATABASE DIRECTORY :scanvar'
  108.     pause
  109.     signal EndProg
  110.  
  111.  
  112. SetColor:
  113.     ansii.esc      = '1B'x
  114.     c.normal       = ansii.esc || '[0m'
  115.     c.highlite     = ansii.esc || '[1m'
  116.     c.blackback    = ansii.esc || '[40m'
  117.     c.green        = c.normal || ansii.esc || '[32m'
  118.     c.grey         = c.normal || ansii.esc || '[37m'
  119.     c.itred        = c.highlite || ansii.esc || '[31m'
  120.     c.itgreen      = c.highlite || ansii.esc || '[32m'
  121.     c.yellow       = c.highlite || ansii.esc || '[33m'
  122.     c.itblue       = c.highlite || ansii.esc || '[34m'
  123.     c.itmagenta    = c.highlite || ansii.esc || '[35m'
  124.     c.itcyan       = c.highlite || ansii.esc || '[36m'
  125.     c.white        = c.highlite || ansii.esc || '[37m'
  126.     c.std          = c.normal || c.itcyan || c.blackback
  127.     c.reset        = c.normal || c.grey || c.blackback
  128.     return 0
  129.