home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / inetlg75.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  2001-09-14  |  34KB  |  966 lines

  1. /* inetcfg
  2. Copyright 2000 - 2001 by Chuck McKinnis,  Sandia Park, NM (USA) 04 Oct 2001
  3. mckinnis@attglobal.net
  4.  
  5. REXX Program to install INetLog, set the parameters for the inetlog.cmd
  6. and ijoylog.cmd, and convert existing an existing inetlog.ini file to inetcfg.cfg
  7.  
  8.    Right to freely use, modify, distribute granted but please acknowledge
  9.    source as a courtesy if you build upon it.  Please pass on comments,
  10.    suggestions, problems to mckinnis@attglobal.net
  11. */
  12. Trace 'N'
  13. Parse Upper Arg otherparms '|' pmrexx
  14. our_parms = otherparms
  15. pmrexx = (pmrexx <> '')
  16.  
  17. /* Where are we ? */
  18. Parse Source . . install_path .
  19. our_prog = install_path
  20. inetlog_program = install_path
  21. install_path = Filespec('D',install_path) || Filespec('P',install_path)
  22. old_ini_file = install_path || 'inetlog.ini'
  23. inetcfg_ini = install_path || 'inetcfg.ini'
  24. inetsmp_ini = install_path || 'inetsmp.ini'
  25. our_path = Strip(install_path, 'T', '\')
  26. save_path = Directory(our_path)
  27. null = '00'x
  28.  
  29. If Rxfuncquery('SysDropFuncs') Then
  30.    Call Rxfuncadd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  31. Call SysLoadFuncs
  32.  
  33. quiet = 0
  34.  
  35. obj_id = '<INETCFG_RUN>'
  36. If \pmrexx Then
  37.    Do
  38.       Call PMRexxGo 'START', obj_id, our_prog, 'Internet Log Anyalyzer Setup', our_parms
  39.       Return
  40.    End
  41.  
  42. Signal On Failure Name errhandler
  43. Signal On Halt Name errhandler
  44. Signal On Syntax Name errhandler
  45.  
  46.  
  47. If Rx_fileexists(inetcfg_ini) Then      /* save any existing ini file */
  48.    Do
  49.       ini_save = Left(inetcfg_ini, Lastpos('.', inetcfg_ini)) || 'sav'
  50.       Address cmd '@copy' inetcfg_ini ini_save '> nul'
  51.    End
  52.  
  53. Call Read_config                              /* read the config file */
  54.  
  55. Call Read_me
  56.  
  57. Call Update_config                   /* update config file parameters */
  58.  
  59. Call Check_config                    /* check for config file updates */
  60.  
  61. Call Update_object                      /* get parameters for INetLog */
  62.  
  63. Call Create_object                /* create/update the INetLog object */
  64.  
  65. Call Cleanup                                   /* end of main program */
  66.  
  67. Return
  68.  
  69. /* read the documentation */
  70. Read_me:
  71. Say 'Would you like to read the documentation? Y/n'
  72. Parse Upper Pull ans .
  73. If \Abbrev(ans, 'N') Then
  74.    Address cmd '@start e.exe' install_path || 'readme.txt'
  75. Say 'Would you like to read the changes list? y/N'
  76. Parse Upper Pull ans .
  77. If Abbrev(ans, 'Y') Then
  78.    Address cmd '@start e.exe' install_path || 'changes.txt'
  79. Say 'Press any key to continue ...'
  80. Parse Upper Pull ans .
  81. Return
  82.  
  83. /* read the config file */
  84. Read_config:
  85. trace_save = Trace('N')
  86. use_sample = 0
  87. Call Config_sample                               /* build inetsmp.ini */
  88. If Rx_fileexists(inetcfg_ini) Then        /* do we have a config file */
  89.    input_file = inetcfg_ini
  90. Else
  91.    Do
  92.       input_file = inetsmp_ini
  93.       use_sample = 1
  94.    End
  95.  
  96. Say 'Using configuration file -' input_file
  97. cfg_common = SysIni(input_file, 'cfg_common', 'cfg_common')
  98. If cfg_common <> 'ERROR:' Then
  99.    Do i = 1 To Words(cfg_common)
  100.       keyid = Word(cfg_common, i)
  101.       Interpret keyid '= sysini("' || input_file || '", "cfg_common", "' || keyid || '")'
  102.    End
  103. Else
  104.    Do
  105.       Say 'cfg_common not found in' input_file
  106.       Call Cleanup
  107.    End
  108. cfg_inetlog = SysIni(input_file, 'cfg_inetlog', 'cfg_inetlog')
  109. If cfg_inetlog <> 'ERROR:' Then
  110.    Do i = 1 To Words(cfg_inetlog)
  111.       keyid = Word(cfg_inetlog, i)
  112.       Interpret keyid '= sysini("' || input_file || '", "cfg_inetlog", "' || keyid || '")'
  113.    End
  114. Else
  115.    Do
  116.       Say 'cfg_inetlog not found in' input_file
  117.       Call Cleanup
  118.    End
  119. cfg_ijoylog = SysIni(input_file, 'cfg_ijoylog', 'cfg_ijoylog')
  120. If cfg_ijoylog <> 'ERROR:' Then
  121.    Do i = 1 To Words(cfg_ijoylog)
  122.       keyid = Word(cfg_ijoylog, i)
  123.       Interpret keyid '= sysini("' || input_file || '", "cfg_ijoylog", "' || keyid || '")'
  124.    End
  125. Else
  126.    Do
  127.       Say 'cfg_ijoylog not found in' input_file
  128.       Call Cleanup
  129.    End
  130. If use_sample Then
  131.    Call Write_config inetcfg_ini, 'all'
  132. Call Convert_ini old_ini_file          /* update from an old ini file */
  133. Call SysIni inetcfg_ini, 'cfg_common', 'what_r_we', what_r_we
  134. Say what_r_we
  135. Trace(trace_save)
  136. Return
  137.  
  138. /* convert or update config using an existing ini file */
  139. Convert_ini:
  140. trace_save = Trace('N')
  141. Parse Arg old_ini_file
  142. If Rx_fileexists(old_ini_file) ,
  143.    & File_cmd(old_ini_file, 'D') > File_cmd(input_file, 'D') Then
  144.    Do
  145.       ini_key = 'IGN InJoy DataPath DisplayDailyReport PauseAsScreenFills' ,
  146.          'WarnPercent ConnectDigits MinuteDigits HourDigits'
  147.       key_key = 'ibm_dialer injoy_dialer data_path daily_report one_screen_at_a_time' ,
  148.          'warn_pct sig_x sig_min sig_hr'
  149.       /* get all keys */
  150.       xrc = SysIni(old_ini_file, 'COMMON', 'ALL:', 'keys.')
  151.       If keys.0 > 0 Then
  152.          Do i = 1 To keys.0                 /* get all the key values */
  153.             key_id = Word(key_key, Wordpos(keys.i, ini_key))
  154.             key_value = "'" || SysIni(old_ini_file, 'COMMON', keys.i) || "'"
  155.             Interpret key_id '=' key_value
  156.          End
  157.       ini_key = 'IniFileName OutputFileName SummaryFileName LastTimeStamp'
  158.       key_key = 'ibm_dialer_ini_file ibm_output_file ibm_summary_file ibm_last_time_stamp'
  159.       /* get all keys */
  160.       xrc = SysIni(old_ini_file, 'INETLOG', 'ALL:', 'keys.')
  161.       If keys.0 > 0 Then
  162.          Do i = 1 To keys.0                 /* get all the key values */
  163.             key_id = Word(key_key, Wordpos(keys.i, ini_key))
  164.             key_value = "'" || SysIni(old_ini_file, 'INETLOG', keys.i) || "'"
  165.             Interpret key_id '=' key_value
  166.          End
  167.       ini_key = 'InJoyOutput InJoySummary'
  168.       key_key = 'injoy_output_file injoy_summary_file'
  169.       /* get all keys */
  170.       xrc = SysIni(old_ini_file, 'IJOYLOG', 'ALL:', 'keys.')
  171.       If keys.0 > 0 Then
  172.          Do i = 1 To keys.0                 /* get all the key values */
  173.             key_id = keys.i
  174.             If Wordpos(key_id, ini_key) > 0 Then
  175.                Do
  176.                   key_id = Word(key_key, Wordpos(keys.i, ini_key))
  177.                   key_value = "'" || SysIni(old_ini_file, 'IJOYLOG', keys.i) || "'"
  178.                   Interpret key_id '=' key_value
  179.                End
  180.          End
  181.       injoy_total_logs = SysIni(old_ini_file, 'IJOYLOG', 'InJoyLogs')
  182.       log_value = ''
  183.       acct_value = ''
  184.       user_value = ''
  185.       time_value = ''
  186.       Do i = 1 To injoy_total_logs
  187.          key = 'InJoyLog_' || i
  188.          log_value = log_value SysIni(old_ini_file, 'IJOYLOG', key)
  189.          If log_value = 'ERROR:' Then
  190.             log_value = Word(SysIni(old_ini_file, 'IJOYLOG', 'InJoyLog'), i)
  191.          key = 'InJoyAcct_' || i
  192.          acct_value = acct_value SysIni(old_ini_file, 'IJOYLOG', key)
  193.          If acct_value = 'ERROR:' Then
  194.             acct_value = Word(SysIni(old_ini_file, 'IJOYLOG', 'InJoyAcct'), i)
  195.          key = 'InJoyUser_' || i
  196.          user_value = user_value SysIni(old_ini_file, 'IJOYLOG', key)
  197.          If user_value = 'ERROR:' Then
  198.             user_value = Word(SysIni(old_ini_file, 'IJOYLOG', 'InJoyUser'), i)
  199.          key = 'InJoyTimeStamp_' || i
  200.          time_value = time_value SysIni(old_ini_file, 'IIJOYLOG', key)
  201.          If time_value = 'ERROR:' Then
  202.             time_value = Word(SysIni(old_ini_file, 'IJOYLOG', 'InJoyTimeStamp'), i)
  203.       End
  204.       If injoy_logs <> '' Then
  205.          injoy_logs = Strip(log_value)
  206.       Else
  207.          injoy_logs = null
  208.       If injoy_accts <> '' Then
  209.          injoy_accts = Strip(acct_value)
  210.       Else
  211.          injoy_accts = null
  212.       If injoy_users <> '' Then
  213.          injoy_users = Strip(user_value)
  214.       Else
  215.          injoy_users = null
  216.       If injoy_times <> '' Then
  217.          injoy_times = Strip(time_value)
  218.       Else
  219.          injoy_times = null
  220.       Call Write_config inetcfg_ini, 'all'
  221.       Address cmd '@rename' old_ini_file 'inetini.sav > nul'
  222.    End
  223. Trace(trace_save)
  224. Return
  225.  
  226. /* update config file */
  227. Update_config:
  228. trace_save = Trace('N')
  229. If \use_sample Then
  230.    Do
  231.       Say 'Update all common data in -'
  232.       Say inetcfg_ini '(y/N)'
  233.       Parse Upper Pull ans .
  234.    End
  235. Else
  236.    ans = 'Y'
  237. If Abbrev(ans, 'Y') Then
  238.    Do
  239.       cfg_common = SysIni(inetsmp_ini, 'cfg_common', 'cfg_common')
  240.       If cfg_common <> 'ERROR:' Then
  241.          Do i = 1 To Words(cfg_common)
  242.             keyid = Word(cfg_common, i)
  243.             Interpret keyid '= sysini("' || inetsmp_ini || '", "cfg_common", "' || keyid || '")'
  244.          End
  245.       Else
  246.          Do
  247.             Say 'Application cfg_common has no keys'
  248.             Call Cleanup
  249.          End
  250.       Call Write_config inetcfg_ini, 'cfg_common'
  251.    End
  252.  
  253. If \use_sample Then
  254.    Do
  255.       Say 'Update all IBM dialer data in -'
  256.       Say inetcfg_ini '(y/N)'
  257.       Parse Upper Pull ans .
  258.    End
  259. Else
  260.    ans = 'Y'
  261. If Abbrev(ans, 'Y') Then
  262.    Do
  263.       cfg_inetlog = SysIni(inetsmp_ini, 'cfg_inetlog', 'cfg_inetlog')
  264.       If cfg_inetlog <> 'ERROR:' Then
  265.          Do i = 1 To Words(cfg_inetlog)
  266.             keyid = Word(cfg_inetlog, i)
  267.             Interpret keyid '= sysini("' || inetsmp_ini || '", "cfg_inetlog", "' || keyid || '")'
  268.          End
  269.       Else
  270.          Do
  271.             Say 'Application cfg_inetlog has no keys'
  272.             Call Cleanup
  273.          End
  274.       Call Write_config inetcfg_ini, 'cfg_inetlog'
  275.    End
  276. If \use_sample Then
  277.    Do
  278.       Say 'Update all InJoy dialer data in -'
  279.       Say inetcfg_ini '(y/N)'
  280.       Parse Upper Pull ans .
  281.    End
  282. Else
  283.    ans = 'Y'
  284. If Abbrev(ans, 'Y') Then
  285.    Do
  286.       cfg_ijoylog = SysIni(inetsmp_ini, 'cfg_ijoylog', 'cfg_ijoylog')
  287.       If cfg_ijoylog <> 'ERROR:' Then
  288.          Do i = 1 To Words(cfg_ijoylog)
  289.             keyid = Word(cfg_ijoylog, i)
  290.             Interpret keyid '= sysini("' || inetsmp_ini || '", "cfg_ijoylog", "' || keyid || '")'
  291.          End
  292.       Else
  293.          Do
  294.             Say 'Application cfg_ijoylog has no keys'
  295.             Call Cleanup
  296.          End
  297.       Call Write_config inetcfg_ini, 'cfg_ijoylog'
  298.    End
  299. Trace(trace_save)
  300. Return
  301.  
  302. /* update the config file */
  303. Check_config:
  304. trace_save = Trace('N')
  305. /* path to data files */
  306. Call SysIni inetcfg_ini, 'cfg_common', 'data_path', data_path
  307.  
  308. /* create the data path sub-directory if needed */
  309. If \Rx_fileexists(data_path) Then
  310.    Call Rx_makepath data_path
  311.  
  312. /* IBM dialer support */
  313. If ibm_dialer = null Then
  314.    Do
  315.       Say 'Support the IBM dialer (y/N)?'
  316.       Parse Upper Pull ans .
  317.       key_value = Abbrev(ans, 'Y')
  318.       ibm_dialer = key_value
  319.       Call SysIni inetcfg_ini, 'cfg_common', 'ibm_dialer', ibm_dialer
  320.    End
  321. /* process IBM dialer entries */
  322. If ibm_dialer Then
  323.    Do
  324.       /* dialer ini file */
  325.       If ibm_dialer_ini_file = null Then
  326.          Do
  327.             Say 'Please select your IBM dialer by number'
  328.             Say '   1 - DIALER.EXE (1.67 and below)'
  329.             Say '   2 - TCPDIAL.EXE (1.69 and above)'
  330.             Parse Upper Pull ans .
  331.             Select
  332.                When ans = 1 Then
  333.                   key_value = 'dialer.ini'
  334.                When ans = 2 Then
  335.                   key_value = 'tcpdial.ini'
  336.                Otherwise Do
  337.                   Say 'You did not chose a supported dialer'
  338.                   key_value = null
  339.                End
  340.             End
  341.             ibm_dialer_ini_file = key_value
  342.          End
  343.       Call Write_config inetcfg_ini, 'cfg_inetlog'
  344.    End
  345.  
  346. /* InJoy dialer support */
  347. If injoy_dialer = null Then
  348.    Do
  349.       Say 'Support the InJoy dialer (y/N)?'
  350.       Parse Upper Pull ans .
  351.       key_value = Abbrev(ans, 'Y')
  352.       injoy_dialer = key_value
  353.       Call SysIni inetcfg_ini, 'cfg_common', 'injoy_dialer', injoy_dialer
  354.    End
  355. /* process InJoy dialer entries */
  356. If injoy_dialer Then
  357.    Do
  358.       If injoy_logs = null Then
  359.          Do
  360.             injoy_accts = null
  361.             injoy_users = null
  362.             injoy_times = null
  363.             /* get path to InJoy */
  364.             Say 'Enter the full path to the InJoy Dialer logs or hit enter to quit.'
  365.             Parse Upper Pull ans .
  366.             If ans <> '' Then
  367.                Do
  368.                   /* get all *.log file names */
  369.                   log_path = ans
  370.                   hosts. = ''
  371.                   accounts. = ''
  372.                   users. = ''
  373.                   logs. = ''
  374.                   x = 0
  375.                   default_host_file = log_path || '\default.cfg'
  376.                   default_host_file = Stream(log_path || '\default.cfg', 'c', 'query exists')
  377.                   If default_host_file <> '' Then
  378.                      Do
  379.                         hosts_dat = ''
  380.                         Do While Chars(default_host_file) > 0
  381.                            hosts_dat = hosts_dat || Charin(default_host_file)
  382.                         End
  383.                         Parse Var hosts_dat . 3 host_name + 8 . 281 account_data_length + 2 . 765 host_log + 12 .
  384.                         account_data_length = X2d(C2x(account_data_length))
  385.                         Parse Var hosts_dat . 286 account_data + (account_data_length) .
  386.                         If Pos('.', account_data) <> 0 Then
  387.                            Do
  388.                               user_name = Substr(account_data, Lastpos('.', account_data) + 1)
  389.                               account_data = Left(account_data, Lastpos('.', account_data) - 1)
  390.                               account_name = Substr(account_data, Lastpos('.', account_data) + 1)
  391.                            End
  392.                         Else
  393.                            Do
  394.                               account_name = ''
  395.                               user_name = Strip(account_data)
  396.                            End
  397.                         host_log = Stream(log_path || '\' || Strip(host_log, , '00'x), 'c', 'query exists')
  398.                         If host_log <> '' Then
  399.                            Do
  400.                               x = x + 1
  401.                               hosts.x = Strip(host_name, , '00'x)
  402.                               accounts.x = account_name
  403.                               users.x = user_name
  404.                               logs.x = Strip(host_log)
  405.                               logs.0 = x
  406.                            End
  407.                      End
  408.                   hosts_dat_file = Stream(log_path || '\hosts.dat', 'c', 'query exists')
  409.                   If hosts_dat_file <> '' Then
  410.                      Do
  411.                         hosts_dat = ''
  412.                         Do While Chars(hosts_dat_file) > 0
  413.                            hosts_dat = hosts_dat || Charin(hosts_dat_file)
  414.                         End
  415.                         Do Until hosts_dat = ''
  416.                            Parse Var hosts_dat host_rec 1178 hosts_dat
  417.                            Parse Var host_rec . 281 account_data_length + 2 . 485 host_name + 8 . 765 host_log + 12 .
  418.                            account_data_length = X2d(C2x(account_data_length))
  419.                            Parse Var host_rec . 286 account_data + (account_data_length) .
  420.                            If Pos('.', account_data) <> 0 Then
  421.                               Do
  422.                                  user_name = Substr(account_data, Lastpos('.', account_data) + 1)
  423.                                  account_data = Left(account_data, Lastpos('.', account_data) - 1)
  424.                                  account_name = Substr(account_data, Lastpos('.', account_data) + 1)
  425.                               End
  426.                            Else
  427.                               Do
  428.                                  account_name = ''
  429.                                  user_name = Strip(account_data)
  430.                               End
  431.                            host_log = Stream(log_path || '\' || Strip(host_log, , '00'x), 'c', 'query exists')
  432.                            If host_log <> '' Then
  433.                               Do
  434.                                  x = x + 1
  435.                                  hosts.x = Space(Translate(host_name, , '5F'x, ' '))
  436.                                  accounts.x = account_name
  437.                                  users.x = user_name
  438.                                  logs.x = Strip(host_log)
  439.                                  logs.0 = x
  440.                               End
  441.                         End
  442.                      End
  443.                   /* loop through log file names to see the user wants them included */
  444.                   If logs.0 > 0 Then
  445.                      Do i = 1 To logs.0
  446.                         Say 'Found InJoy log file -' logs.i '- for host -' hosts.i
  447.                         Say 'Analyze this log (y/N)'
  448.                         Parse Upper Pull ans
  449.                         If Abbrev(ans, 'Y') Then
  450.                            Do
  451.                               injoy_logs = Space(injoy_logs logs.i)
  452.                               If accounts.i <> '' Then
  453.                                  injoy_accts = Space(injoy_accts accounts.i)
  454.                               Else
  455.                                  Do
  456.                                     Say 'Enter an account id for InJoy log (enter = none)'
  457.                                     Say logs.i
  458.                                     Parse Pull accounts.i
  459.                                     If accounts.i = '' Then
  460.                                        accounts.i = 'none'
  461.                                     injoy_accts = Strip(injoy_accts accounts.i)
  462.                                  End
  463.                               If users.i <> '' Then
  464.                                  injoy_users = Space(injoy_users users.i)
  465.                               Else
  466.                                  Do
  467.                                     Say 'Enter an user id for InJoy log (enter = none)'
  468.                                     Say log.i 'and account id -' accounts.i
  469.                                     Parse Pull users.i
  470.                                     If users.i = '' Then
  471.                                        users.i = 'none'
  472.                                     injoy_users = Strip(injoy_users users.i)
  473.                                  End
  474.                               times.i = 'T00000000000000'
  475.                               injoy_times = Strip(injoy_times times.i)
  476.                            End
  477.                      End
  478.                   Else
  479.                      Do
  480.                         Say 'Unable to locate any logs in InJoy log path -' ans
  481.                         Say 'InJoy logs in' ans 'will not be processed.'
  482.                      End
  483.                End
  484.             Else
  485.                Say 'InJoy logs will not be processed'
  486.             If injoy_logs <> null Then
  487.                injoy_logs = Space(Translate(injoy_logs, , null))
  488.             If injoy_accts <> null Then
  489.                injoy_accts = Space(Translate(injoy_accts, , null))
  490.             If injoy_users <> null Then
  491.                injoy_users = Space(Translate(injoy_users, , null))
  492.             If injoy_times <> null Then
  493.                injoy_times = Space(Translate(injoy_times, , null))
  494.          End
  495.       Call Write_config inetcfg_ini, 'cfg_ijoylog'
  496.    End
  497. Trace(trace_save)
  498. Return
  499.  
  500. /* write the config file */
  501. Write_config:
  502. trace_save = Trace('N')
  503. Parse Arg ini_file, ini_appl
  504. If ini_appl = '' Then
  505.    ini_appl = 'all'
  506. If ini_appl = 'all' | ini_appl = 'cfg_common' Then
  507.    Do
  508.       Call SysIni ini_file, 'cfg_common', 'cfg_common', cfg_common
  509.       Do i = 1 To Words(cfg_common)
  510.          Call SysIni ini_file, 'cfg_common', Word(cfg_common, i), Value(Word(cfg_common, i))
  511.       End
  512.    End
  513. If ini_appl = 'all' | ini_appl = 'cfg_inetlog' Then
  514.    Do
  515.       Call SysIni ini_file, 'cfg_inetlog', 'cfg_inetlog', cfg_inetlog
  516.       Do i = 1 To Words(cfg_inetlog)
  517.          Call SysIni ini_file, 'cfg_inetlog', Word(cfg_inetlog, i), Value(Word(cfg_inetlog, i))
  518.       End
  519.    End
  520. If ini_appl = 'all' | ini_appl = 'cfg_ijoylog' Then
  521.    Do
  522.       Call SysIni ini_file, 'cfg_ijoylog', 'cfg_ijoylog', cfg_ijoylog
  523.       Do i = 1 To Words(cfg_ijoylog)
  524.          Call SysIni ini_file, 'cfg_ijoylog', Word(cfg_ijoylog, i), Value(Word(cfg_ijoylog, i))
  525.       End
  526.    End
  527.  
  528. Trace(trace_save)
  529. Return
  530.  
  531. /* Get parameters for the INetLog object */
  532. Update_object:
  533. parmlist = ''
  534. If ibm_dialer | injoy_dialer Then
  535.    Do
  536.       Say 'Do you want daily reports? y/N'
  537.       Parse Upper Pull ans .
  538.       If Abbrev(ans, 'Y') Then
  539.          daily_report = 1
  540.       Else
  541.          daily_report = 0
  542.       Call SysIni inetcfg_ini, 'cfg_common', 'daily_report', daily_report
  543.       Say 'Do you want to run without output to the screen'
  544.       Say 'and only generate the report files? y/N'
  545.       Parse Upper Pull ans .
  546.       If Abbrev(ans, 'Y') Then
  547.          parmlist = parmlist 'QUIET'
  548.    End
  549. If ibm_dialer & injoy_dialer Then
  550.    Do
  551.       Say 'Do you want:'
  552.       Say '   1 - individual reports for the IBM dialer and the'
  553.       Say '       InJoy dialer'
  554.       Say '   2 - a combined report for the IBM dialer and the'
  555.       Say '       InJoy dialer as well as a report for each dialer'
  556.       Say '   3 - only a combined report for both the IBM dialer'
  557.       Say '       and the InJoy dialer'
  558.       Say 'Select an option number'
  559.       Parse Upper Pull ans .
  560.       Select
  561.          When ans = 1 Then
  562.             Say 'Individual reports for all dialers will be generated'
  563.          When ans = 2 Then
  564.             Do
  565.                Say 'A combined report for all dialers will be generated'
  566.                parmlist = parmlist 'COMBINE'
  567.             End
  568.          When ans = 3 Then
  569.             Do
  570.                Say 'Only a combined report for all dialers will be generated'
  571.                parmlist = parmlist 'COMBINEONLY'
  572.             End
  573.          Otherwise Do
  574.             Say 'Invalid selection'
  575.             Say 'Individual reports for all dialers will be generated'
  576.          End
  577.       End
  578.    End
  579. parmlist = Space(parmlist)
  580. Return
  581.  
  582. /* Create INetLog objects */
  583. Create_object:
  584.  
  585. /* Create INetLog folder */
  586. classname = 'WPFolder'
  587. location = '<WP_DESKTOP>'
  588. title = 'Internet Log^Analyzer'
  589. setup = 'OBJECTID=<WP_INETLOG>;'
  590. If SysCreateObject(classname, title, location, setup, 'U') Then
  591.    Do
  592.       Say 'INetLog folder created/updated successfully'
  593.  
  594.       /* Create INetLog object */
  595.       classname = 'WPProgram'
  596.       location = '<WP_INETLOG>'
  597.       title = 'Dialer Log^Analyzer'
  598.       obj = 'OBJECTID=<INETLOGP>;'
  599.       iconfile = 'ICONFILE=' || our_path || '\INETLOG.ICO;'
  600.       our_exec = Stream(our_path || '\inetlog.cmd', 'c', 'query exists')
  601.       exename = 'EXENAME=' || our_exec || ';'
  602.       startupdir = 'STARTUPDIR=' || our_path || ';'
  603.       setup = obj || iconfile || exename || startupdir || 'MINIMIZED=YES;'
  604.       If parmlist <> '' Then
  605.          setup = setup || 'PARAMETERS=' || parmlist || ';'
  606.       If SysCreateObject(classname, title, location, setup, 'U') Then
  607.          Do
  608.             Say 'INetLog object created/updated successfully'
  609.             rc = SysMkDir(our_path || '\DATA')
  610.          End
  611.       Else
  612.          Say 'Unable to create/update INetLog object'
  613.  
  614.       /* Create INetCfg object */
  615.       classname = 'WPProgram'
  616.       location = '<WP_INETLOG>'
  617.       title = 'Dialer Log^Configurator'
  618.       obj = 'OBJECTID=<INETLOGC>;'
  619.       iconfile = 'ICONFILE=' || our_path || '\INETLOG.ICO;'
  620.       our_exec = Stream(our_path || '\install.cmd', 'c', 'query exists')
  621.       exename = 'EXENAME=' || our_exec || ';'
  622.       startupdir = 'STARTUPDIR=' || our_path || ';'
  623.       setup = obj || iconfile || exename || startupdir || 'MINIMIZED=NO;'
  624.       If SysCreateObject(classname, title, location, setup, 'U') Then
  625.          Say 'INetCfg object created/updated successfully'
  626.       Else
  627.          Say 'Unable to create/update INetCfg object'
  628.    End
  629. Else
  630.    Say 'Unable to create/update INetLog folder'
  631.  
  632. Return
  633.  
  634. Errhandler:
  635. Call Beep 300, 500
  636. Say 'Rexx error' rc 'in line' sigl||':' Errortext(rc)
  637. Say Sourceline(sigl)
  638. Call Cleanup
  639. Return
  640.  
  641. Cleanup:                                                      /* Exit */
  642. Say 'Press any key to exit...'
  643. Parse Upper Pull .
  644. If Rx_fileexists(inetsmp_ini) Then
  645.    Call SysFileDelete inetsmp_ini
  646. save_path = Directory(save_path)
  647. Call PMRexxGo 'EXIT', obj_id
  648. Return                                                 /* for Cleanup */
  649.  
  650. /* performs common Stream commands and returns 1 or a date if successful */
  651. File_cmd: Procedure Expose result
  652. trace_save = Trace('N')
  653. Parse Arg file_name, command
  654. command = Translate(command)
  655. Select
  656.    When command = 'X' Then
  657.       Do
  658.          result = Stream(file_name, 'c', 'QUERY EXISTS')
  659.          answer = (result <> '')
  660.       End
  661.    When command = 'C' Then
  662.       Do
  663.          result = Stream(file_name, 'C', 'CLOSE')
  664.          answer = Abbrev(result,'READY') | (result = '')
  665.       End
  666.    When command = 'W' Then
  667.       Do
  668.          result = Stream(file_name, 'C', 'OPEN WRITE')
  669.          answer = Abbrev(result,'READY')
  670.       End
  671.    When command = 'R' Then
  672.       Do
  673.          result = Stream(file_name, 'C', 'OPEN READ')
  674.          answer = Abbrev(result,'READY')
  675.       End
  676.    When command = 'D' Then
  677.       Do
  678.          result = Stream(file_name, 'C', 'QUERY DATETIME')
  679.          If result <> '' Then
  680.             Do
  681.                Parse Var result date time
  682.                date = Dateconv(Translate(date, '/', '-'), 'U', 'S')
  683.                Parse Var time hr ':' min ':' sec
  684.                answer = Strip(date) || Strip(hr) || Strip(min) || Strip(sec)
  685.             End
  686.          Else
  687.             answer = '00000000000000'
  688.       End
  689.    Otherwise answer = 0
  690. End
  691. Trace(trace_save)
  692. Return answer
  693.  
  694. Say_out:                             /* performs output to the screen */
  695. Procedure Expose quiet
  696. trace_save = Trace('N')
  697. If quiet Then
  698.    Return
  699. Parse Arg line
  700. Say line
  701. Trace(trace_save)
  702. Return
  703.  
  704. Say_message:       /* performs message output and returns key entered */
  705. Procedure Expose quiet
  706. trace_save = Trace('N')
  707. Parse Arg msg
  708. Say msg
  709. answer = SysGetKey('NOECHO')
  710. Trace(trace_save)
  711. Return answer
  712.  
  713. Log_file_parms: Procedure
  714. trace_save = Trace('N')
  715. Parse Arg dialer_ini_name, dialer_ini
  716. Select
  717.    When Translate(dialer_ini_name) = 'DIALER.INI' Then
  718.       Do
  719.          dlog_eparm = 'AdvLog'
  720.          dlog_nparm = 'Cfn'
  721.          dlog_sparm = 'Cfs'
  722.       End
  723.    When Translate(dialer_ini_name) = 'TCPDIAL.INI' Then
  724.       Do
  725.          dlog_eparm = 'Common'
  726.          dlog_nparm = 'LoggingCfn'
  727.          dlog_sparm = 'LoggingCfs'
  728.       End
  729.    Otherwise Do
  730.       Say 'Unable to recognize dialer ini file'
  731.       Call Cleanup
  732.       Exit
  733.    End
  734. End
  735. dialer_log_file = Strip(SysIni(dialer_ini, dlog_eparm, dlog_nparm),,'00'x)
  736. dialer_log_size = C2d(Left(SysIni(dialer_ini, dlog_eparm, dlog_sparm),3))
  737. Trace(trace_save)
  738. Return dialer_log_file dialer_log_size
  739.  
  740. /* set up config sample values */
  741. Config_sample:
  742. trace_save = Trace('N')
  743. /* inetsmp.ini configuration file
  744.    This file is read at startup to provide parameters
  745.    for the inetlog.cmd and the ijoylog.cmd */
  746.  
  747. /* common values */
  748. cfg_common = 'what_r_we ibm_dialer ibm_dialer injoy_dialer data_path daily_report warn_pct sig_x sig_min sig_hr'
  749. /* version and date */
  750. what_r_we = 'INetLog  v7.5 04 Oct 2001, Copyright 1995 - 2001 by Chuck McKinnis and Jerry Levy'
  751. /* process IBM dialer logs (1 = yes, 0 = no) */
  752. ibm_dialer = null
  753. /* process InJoy dialer logs (1 = yes, 0 = no) */
  754. injoy_dialer = null
  755. /* path to data files - normally x:\inetlog\data */
  756. data_path = install_path || 'data\'
  757. /* display daily reports (1 = yes, 0 = no) */
  758. daily_report = 0
  759. /* warn if the IBM dialer log exceeds this percentage of the size */
  760. warn_pct = 85
  761. /* Leading digits for connects, minutes, hours per day or month
  762.    You should not need to change these.  If you exceed 9,999
  763.    connects, 9,999,999 minutes, or 999,999 hours per period
  764.    you will crash, but then I think you have other problems */
  765. /* significant digits for connects/day or conects/month */
  766. sig_x = 4
  767. /* ... for minutes/day or minutes/month */
  768. sig_min = 7
  769. /* ... for hours/day or hours/month */
  770. sig_hr = 6
  771.  
  772. /* ibm log values */
  773. cfg_inetlog = 'ibm_dialer_ini_file ibm_output_file ibm_summary_file ibm_last_time_stamp'
  774. /* name of the IBM dialer ini file */
  775. ibm_dialer_ini_file = null
  776. /* output file for IBM dialer detail report */
  777. ibm_output_file = data_path || 'inetlog.log'
  778. /* output file for IBM dialer summary report */
  779. ibm_summary_file = data_path || 'inetsum.log'
  780. /* time stamp for last processed record of IBM dialer log */
  781. ibm_last_time_stamp = 'T00000000000000'
  782.  
  783. /* injoy log values */
  784. cfg_ijoylog = 'injoy_logs injoy_accts injoy_users injoy_times injoy_output_file injoy_summary_file'
  785. /* path(s) to the InJoy dialer log file(s) */
  786. injoy_logs = null
  787. /* account(s) for the InJoy dialer log file(s) */
  788. injoy_accts = null
  789. /* users(s) for the InJoy dialer log file(s) */
  790. injoy_users = null
  791. /* time stamp(s) for the InJoy dialer log file(s) */
  792. injoy_times = null
  793. /* output file for InJoy dialer detail report */
  794. injoy_output_file = data_path || 'ijoylog.log'
  795. /* output file for InJoy dialer summary report */
  796. injoy_summary_file = data_path || 'ijoysum.log'
  797.  
  798. /* build inetsmp.ini */
  799. If Rx_fileexists(inetsmp_ini) Then
  800.    Call SysFileDelete inetsmp_ini
  801. Call Write_config inetsmp_ini, 'all'
  802.  
  803. Trace(trace_save)
  804. Return
  805.  
  806. /* RxSearchLibpath
  807.    search the current libpath for a module
  808.    returns the fully qualified path if found or null if not found
  809.    Copyright 2000 by Chuck McKinnis,  Sandia Park, NM (USA) 04 Feb 2000
  810.    mckinnis@attglobal.net */
  811. Rxsearchlibpath: Procedure
  812. Trace('N')
  813. Parse Arg dll
  814. boot_drive = SysBootDrive()
  815. config_sys = boot_drive || '\config.sys'
  816. xrc = SysFileSearch('libpath', config_sys, 'lib_path.')
  817. If xrc = 0 & lib_path.0 <> 0 Then
  818.    Do i = 1 To lib_path.0
  819.       lib_test = Space(Translate(lib_path.i))
  820.       If Abbrev(lib_test, 'REM') Then
  821.          Iterate i
  822.       If \Abbrev(lib_test, 'LIBPATH') Then
  823.          Iterate i
  824.       lib_equal = Space(Substr(lib_test, 8))
  825.       If \Abbrev(lib_equal, '=') Then
  826.          Iterate i
  827.       Parse Var lib_test . '=' lib_path
  828.    End
  829. lib_path = Space(lib_path)
  830. our_path = SysTempFileName('lib????')
  831. old_value = Value(our_path, lib_path, 'os2environment')
  832. dll_path = SysSearchPath(our_path, dll)
  833. old_value = Value(our_path, old_value, 'os2environment')
  834. Return dll_path
  835.  
  836. /*:VRX         Rx_makepath
  837. Usage:  rx_makepath(path_name)
  838. Where:     path_name = fully qualified name of path to be created
  839. Result:    1 if path created or exists, 0 otherwise
  840. */
  841. Rx_makepath: Procedure Expose verbose log_out log_file
  842. save_trace = Trace('N')
  843. Parse Upper Arg path_name
  844. If \Datatype(verbose, 'b') Then
  845.    verbose = 1
  846. If \Datatype(log_out, 'b') Then
  847.    Do
  848.       xrc = SysFileTree(log_file, 'test.', 'fo')
  849.       If xrc = 0 & test.0 <> 0 Then
  850.          log_out = 1
  851.       Else
  852.          log_out = 0
  853.    End
  854. path_name = Strip(path_name, 't', '\')
  855. xrc = SysFileTree(path_name, 'test.', 'do')
  856. If xrc = 0 & test.0 <> 0 Then
  857.    xrc = 1
  858. Else
  859.    Do
  860.       If Pos(':\', path_name) = 2 Then
  861.          Do
  862.             path_name = path_name || '\'
  863.             path. = ''
  864.             path.0 = 0
  865.             path_pos = Pos('\', path_name, 4 )
  866.             Do i = 1 Until path_pos = 0
  867.                path.i = Left(path_name, path_pos - 1)
  868.                path.0 = i
  869.                path_pos = Pos('\', path_name, path_pos + 1)
  870.             End
  871.             Do i = 1 To path.0
  872.                xrc = SysFileTree(path.i, 'test.', 'do')
  873.                If xrc = 0 & test.0 <> 0 Then
  874.                   xrc = 1
  875.                Else
  876.                   Do
  877.                      xrc = SysMkDir(path.i)
  878.                      xrc = (xrc = 0)
  879.                   End
  880.             End
  881.          End
  882.       Else
  883.          xrc = 0
  884.    End
  885. Trace(save_trace)
  886. Return xrc
  887.  
  888. /*:VRX         rx_fileexists
  889. Usage:  rx_fileexists(file_name)
  890. Where:     file_name = name of file or path to be tested
  891. Result:    1 if file or path exists, 0 otherwise
  892. */
  893. Rx_fileexists: Procedure Expose verbose log_out log_file
  894. save_trace = Trace('N')
  895. Parse Arg file_name
  896. If \Datatype(verbose, 'b') Then
  897.    verbose = 1
  898. If \Datatype(log_out, 'b') Then
  899.    Do
  900.       xrc = SysFileTree(log_file, 'test.', 'fo')
  901.       If xrc = 0 & test.0 <> 0 Then
  902.          log_out = 1
  903.       Else
  904.          log_out = 0
  905.    End
  906. xrc = SysFileTree(file_name, 'test.', 'fo')
  907. If xrc = 0 & test.0 <> 0 Then
  908.    exists = 1
  909. Else
  910.    Do
  911.       /* may be a directory */
  912.       xrc = SysFileTree(file_name, 'test.', 'do')
  913.       If xrc = 0 & test.0 <> 0 Then
  914.          exists = 1
  915.       Else
  916.          exists = 0
  917.    End
  918. Trace(save_trace)
  919. Return exists
  920.  
  921. /*:VRX         PMRexxGo
  922. */
  923. /* setup to run under PMREXX */
  924. Pmrexxgo: Procedure Expose quiet
  925. save_trace = Trace('N')
  926. Parse Arg action, obj_id, our_prog, title, our_parms
  927. obj_id = '<' || obj_id || '>'
  928.  
  929. If action = 'START' Then
  930.    Do
  931.       our_dir = Left(our_prog, Lastpos('\', our_prog) - 1)
  932.       pmrexx_name = SysSearchPath('PATH', 'PMREXX.EXE')
  933.       If pmrexx_name <> '' Then
  934.          Do
  935.             class = 'WPProgram'
  936.             location = '<WP_DESKTOP>'
  937.             obj = 'OBJECTID=' || obj_id || ';'
  938.             exec = 'EXENAME=' || pmrexx_name || ';'
  939.             parm = 'PARAMETERS=' || our_prog our_parms '| X' || ';'
  940.             startdir = 'STARTUPDIR=' || our_dir || ';'
  941.             window = 'MAXIMIZED=NO;MINIMIZED=NO;NOAUTOCLOSE=NO;'
  942.             setup = obj || exec || parm || startdir || window
  943.             rc = SysCreateObject(class, title, location, setup, 'R')
  944.             If rc Then
  945.                Do
  946.                   rc = SysSetObjectData(obj_id, 'OPEN=DEFAULT;CCVIEW=NO;')
  947.                   If rc Then
  948.                      Call Say_out 'Started' title 'under PMRexx'
  949.                   Else
  950.                      Call Say_out 'Unable to start' title 'under PMRexx'
  951.                   Exit
  952.                End
  953.             Else
  954.                Call Say_out 'Unable to create object' title
  955.          End
  956.    End
  957. Else
  958.    Do
  959.       Call Say_out 'Press enter to terminate this program'
  960.       Parse Upper Pull .
  961.       Call SysDestroyObject obj_id
  962.       Call SysSleep 2
  963.    End
  964. Trace(save_trace)
  965. Return
  966.