home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / db22fr.zip / MON_LOGS.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-12  |  7KB  |  193 lines

  1. /*
  2.  ┌──────────────────────────────────────────────────────────────────┐
  3.  │  Name       : mon_log.cmd                                        │
  4.  │  Purpose    : Monitor log files for FRDEMO                       │
  5.  │  Platform   : DB2/2 and OS/2 2.1                                 │
  6.  │  Author     : Jeff Fisher                                        │
  7.  │               Copyright IBM Corporation 1993                     │
  8.  │               IBM Toronto Development Lab                        │
  9.  │                                                                  │
  10.  │  Written    : 02/12/93                                           │
  11.  │                                                                  │
  12.  │  Notes      : The log file directory is hard coded in this       │
  13.  │               program. You'll need to change it to whereever     │
  14.  │               it ends up on your system. Better yet, use some    │
  15.  │               of the ideas presented in MON_DB.CMD to look for   │
  16.  │               a list of databases, present them on the screen,   │
  17.  │               then use the DB Config file to find the log path   │
  18.  │               and finally do the DIR on it. This would make      │
  19.  │               for a more flexible usable program.                │
  20.  │                                                                  │
  21.  └──────────────────────────────────────────────────────────────────┘
  22. */
  23.  
  24. /* signal on syntax */
  25. /*  signal on error  */
  26.  
  27. call ProgramInitialize
  28. call DIRlogs
  29. call EndProg
  30.  
  31. DIRlogs:
  32. /*
  33.  ┌──────────────────────────────────────────────────────────────────┐
  34.  │    DIRlogs                                                       │
  35.  │                                                                  │
  36.  │    Do a DIR on the active log files - helps find out what logs   │
  37.  │  are left/active.                                                │
  38.  │                                                                  │
  39.  └──────────────────────────────────────────────────────────────────┘
  40. */
  41.     call SysCls
  42.     tod = time()
  43.     say c.yellow  '---> Active log files at' tod c.itgreen
  44.  
  45.     step = 'dir the LOG files'
  46.     address cmd 'dir d:\sql00001\sqlogdir\*.log'
  47.     if RC = 3 then
  48.         do
  49.             say c.itred
  50.             say c.itred '---> There are no log files at' tod
  51.             say c.itred
  52.         end
  53.     else
  54.         if RC \= 0 then signal ErrorRC
  55.  
  56.     say c.itblue '<enter> to continue;  <X> to end:'
  57.  
  58.     row = 9
  59.     col = 35
  60.     pos = SysCurPos(row,col)
  61.     choice = SysGetKey('NOECHO')
  62.  
  63.     if choice = 'X' | choice = 'x' then return
  64.  
  65.     signal DIRlogs
  66.  
  67.  
  68.  
  69. EndProg:
  70. /*
  71.  ┌──────────────────────────────────────────────────────────────────┐
  72.  │    EndProg                                                       │
  73.  │                                                                  │
  74.  │                                                                  │
  75.  └──────────────────────────────────────────────────────────────────┘
  76. */
  77.     say c.reset
  78.  
  79.     'exit'
  80.  
  81.  
  82.  
  83.  
  84. ErrorRC:
  85. /*
  86.  ┌──────────────────────────────────────────────────────────────────┐
  87.  │    ErrorRC                                                       │
  88.  │                                                                  │
  89.  │    RC Error routine - handles CMD.EXE return code                │
  90.  │                                                                  │
  91.  └──────────────────────────────────────────────────────────────────┘
  92. */
  93.     tod = time()
  94.     call beep 100,200
  95.     say c.itred
  96.     say '        >>>  OS/2 has returned a fatal condition code'
  97.     say '             abending step = ' step
  98.     say '             source line   = ' sourceline(sigl)
  99.     say '                      time = ' tod
  100.     say '                        RC = ' RC
  101.     say '                    RESULT = ' RESULT
  102.     say
  103.     pause
  104.     signal EndProg
  105.  
  106.  
  107. Error:
  108. /*
  109.  ┌──────────────────────────────────────────────────────────────────┐
  110.  │    Error                                                         │
  111.  │                                                                  │
  112.  │    Rexx Error handling routine                                   │
  113.  │                                                                  │
  114.  └──────────────────────────────────────────────────────────────────┘
  115. */
  116.     tod = time()
  117.     call beep 220,1000
  118.     say c.itred
  119.     say '        >>>  Rexx has returned a signal on error'
  120.     say '             abending step = ' step
  121.     say '             source line   = ' sourceline(sigl)
  122.     say '                        RC = ' RC
  123.     say '                      time = ' tod
  124.     say
  125.     pause
  126.     signal EndProg
  127.  
  128.  
  129. Syntax:
  130. /*
  131.  ┌──────────────────────────────────────────────────────────────────┐
  132.  │    Syntax                                                        │
  133.  │                                                                  │
  134.  │    Rexx Error handling routine                                   │
  135.  │                                                                  │
  136.  └──────────────────────────────────────────────────────────────────┘
  137. */
  138.     call beep 220,1000
  139.     say c.itred
  140.     say '        >>>  Rexx has returned a signal on syntax'
  141.     say '             abending step = ' step
  142.     say '             source line   = ' sourceline(sigl)
  143.     say
  144.     pause
  145.     signal EndProg
  146.  
  147.  
  148. ProgramInitialize:
  149. /*
  150.  ┌──────────────────────────────────────────────────────────────────┐
  151.  │    ProgramInitialize                                             │
  152.  │                                                                  │
  153.  │    Setup all of the variables used in the program, also calls    │
  154.  │  the SetColor routine to setup colors.                           │
  155.  │                                                                  │
  156.  └──────────────────────────────────────────────────────────────────┘
  157. */
  158.     call RxFuncAdd 'SQLDBS','SQLAR','SQLDBS'
  159.     call RxFuncAdd 'SQLEXEC','SQLAR','SQLEXEC'
  160.     address cmd '@ECHO OFF'
  161.     address cmd 'CLS'
  162.     call SetColor
  163.  
  164.     return
  165.  
  166.  
  167. SetColor:
  168. /*
  169.  ┌──────────────────────────────────────────────────────────────────┐
  170.  │    SetColor                                                      │
  171.  │                                                                  │
  172.  │    This paragragh sets the colors used in the program.           │
  173.  │                                                                  │
  174.  └──────────────────────────────────────────────────────────────────┘
  175. */
  176.     ansii.esc      = '1B'x
  177.     c.normal       = ansii.esc || '[0m'
  178.     c.highlite     = ansii.esc || '[1m'
  179.     c.blackback    = ansii.esc || '[40m'
  180.     c.green        = c.normal || ansii.esc || '[32m'
  181.     c.grey         = c.normal || ansii.esc || '[37m'
  182.     c.red          = c.normal || ansii.esc || '[31m'
  183.     c.itred        = c.highlite || ansii.esc || '[31m'
  184.     c.itgreen      = c.highlite || ansii.esc || '[32m'
  185.     c.yellow       = c.highlite || ansii.esc || '[33m'
  186.     c.itblue       = c.highlite || ansii.esc || '[34m'
  187.     c.itmagenta    = c.highlite || ansii.esc || '[35m'
  188.     c.itcyan       = c.highlite || ansii.esc || '[36m'
  189.     c.white        = c.highlite || ansii.esc || '[37m'
  190.     c.std          = c.normal || c.itcyan || c.blackback
  191.     c.reset        = c.normal || c.grey || c.blackback
  192.     return 0
  193.