home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ircii30.zip / script / syscheck < prev    next >
Text File  |  1996-03-02  |  6KB  |  222 lines

  1. # Checks for some unix utilites, used often in scripts. Reports wich dll's
  2. # or .EXEs are missing
  3.  
  4. @ old_novice = novice
  5.  
  6. ^set novice off
  7.  
  8. @ missing.dlls = []
  9. @ missing.exes = []
  10.  
  11. alias run_exe {
  12.     @ re.exe = [$0]
  13.     @ re.old_sh = SHELL
  14.     @ re.old_sh_f = SHELL_FLAGS
  15.     @ re.error = 0
  16.     ^set SHELL cmd
  17.     ^set SHELL_FLAGS /c
  18.     ^on ^exec_error "run_exe SYS1804: The system cannot find the file *." {
  19.         if (!match($8DLL $missing.dlls)) {
  20.             if (missing_dlls) {
  21.                 @ missing.dlls = missing.dlls ## [ ] ## [$8DLL]
  22.             }{
  23.                 @ missing.dlls = [$8DLL]
  24.             }
  25.         }
  26.         @ re.error = 1
  27.     }
  28.     ^on ^exec_error "run_exe SYS1041:*" {
  29.         if (!match($re.exe $missing.exes)) {
  30.             if (missing.exes) {
  31.                 @ missing.exes = missing.exes ## [ ] ## re.exe
  32.             }{
  33.                 @ missing.exes = re.exe
  34.             }
  35.         }
  36.         @ re.error = 1
  37.     }
  38.     ^on ^exec_error "run_exe *" #
  39.     ^on ^exec "run_exe *" #
  40.     exec -name run_exe $0-
  41.     wait %run_exe
  42.     if (re.error) {
  43.         echo *** $re.exe\        test failed!
  44.     }{
  45.         echo *** $re.exe\        test passed...
  46.     }
  47.     ^on ^exec_error -"run_exe SYS1804: The system cannot find the file *."
  48.     ^on ^exec_error -"run_exe SYS1041:*"
  49.     ^on ^exec_error -"run_exe *"
  50.     ^on ^exec -"run_exe *"
  51.     ^set SHELL $re.old_sh
  52.     ^set SHELL_FLAGS $re.old_sh_f
  53.     ^assign -re.exe
  54.     ^assign -re.old_sh
  55.     ^assign -re.old_sh_f
  56.     @ function_return = re.error
  57.     ^assign -re.error
  58. }
  59.  
  60. alias test_ls_exe_ok {
  61.     @ re.exe = [$0]
  62.     @ re.old_sh = SHELL
  63.     @ re.old_sh_f = SHELL_FLAGS
  64.     @ re.error = 1
  65.     ^set SHELL cmd
  66.     ^set SHELL_FLAGS /c
  67.  
  68.     ^exec -name blah_crap echo blahcrapblah > delete.me
  69.     wait %blah_crap
  70.     ^on ^exec "ls_test *" #
  71.     ^on ^exec_error "ls_test *" #
  72.     ^on ^exec "ls_test *delete.me*" {
  73.         if (([$5]==15) && ([$9]==[delete.me])) {
  74.             @ re.error = 0
  75.         }{
  76.             @ re.error = [$1-]
  77.         }
  78.     }
  79.     
  80.     ^exec -name ls_test ls -al
  81.     wait %ls_test
  82.     ^exec -name ls_delete del delete.me
  83.     wait %ls_delete
  84.  
  85.     if (re.error) {
  86.         echo *** Error: LS is displaying data in wrong (non-unix format)
  87.         echo ***
  88.         echo *** Expected : -rw-rw-rw-   1 user     group        15 Mar 01 10:14 delete.me
  89.         echo *** LS output: $re.error
  90.         echo ***
  91.         echo *** This mean that you have another LS.EXE or LS.CMD somewhere on the PATH
  92.         echo *** before LS.EXE included with IrcII/OS2. Please search directories on your
  93.                 echo *** PATH for LS.* and delete all copies except one included with IrcII/OS2
  94.         echo
  95.     }{
  96.         echo *** LS.EXE output format test passed
  97.     }
  98.  
  99.     ^on ^exec -"ls_test *"
  100.     ^on ^exec_error -"ls_test *" #
  101.     ^on ^exec -"ls_test *delete.me*"
  102.     ^set SHELL $re.old_sh
  103.     ^set SHELL_FLAGS $re.old_sh_f
  104.     ^assign -re.exe
  105.     ^assign -re.old_sh
  106.     ^assign -re.old_sh_f
  107.     ^assign -re.error
  108. }
  109.  
  110. alias test_cat_exe_ok {
  111.     @ re.exe = [$0]
  112.     @ re.old_sh = SHELL
  113.     @ re.old_sh_f = SHELL_FLAGS
  114.     @ re.error = 1
  115.     ^set SHELL sh
  116.     ^set SHELL_FLAGS -c
  117.  
  118.     ^on ^exec "cat_test blahcrapblah" {
  119.         @ re.error = 0
  120.     }
  121.  
  122.     ^exec -name cat_test echo blahcrapblah| cat
  123.     wait %cat_test
  124.  
  125.     ^on ^exec -"cat_test blahcrapblah"
  126.  
  127.  
  128.     if (re.error) {
  129.         echo *** Error: CAT dosn't echoing data correctly
  130.         echo ***
  131.         echo *** CAT is unix utility that just echoing all its input to output
  132.         echo *** We are executed "/exec echo blahcrapblah | cat", but cat doesnt
  133.         echo *** echoing "blahcrapblah" back
  134.         echo ***
  135.         echo *** This mean that you some other CAT.EXE or CAT.CMD somewhere on the PATH
  136.         echo *** before CAT.EXE included with IrcII/OS2. Please search directories on your
  137.                 echo *** PATH for CAT.* and delete or rename all copies except one included with 
  138.         echo *** IrcII/OS2
  139.     }{
  140.         echo *** CAT.EXE output format test passed
  141.     }
  142.  
  143.     ^set SHELL $re.old_sh
  144.     ^set SHELL_FLAGS $re.old_sh_f
  145.     ^assign -re.exe
  146.     ^assign -re.old_sh
  147.     ^assign -re.old_sh_f
  148.     ^assign -re.error
  149. }
  150.  
  151. alias run_all_tests {
  152.     echo *** -----------------------------------------------------------------
  153.     echo *** Testing if all vital unix utilites are working. If you will see
  154.     echo *** any errors, almoust all unix scripts will fail to work correctly
  155.     echo *** -----------------------------------------------------------------
  156.     @ sh_ok = run_exe(SH.EXE ------------)
  157.     @ ls_ok = run_exe(LS.EXE)
  158.     @ cat_ok = run_exe(CAT.EXE --version)
  159.     run_exe RM.EXE --version
  160.     run_exe TAIL.EXE --version
  161.     run_exe HEAD.EXE --version
  162.     run_exe WC.EXE --version
  163.     run_exe FMT.EXE --version
  164.  
  165.     echo ***
  166.  
  167.     if (missing.dlls) {
  168.         echo *** Missing DLL's \($missing.dlls\\)
  169.     }
  170.     if (missing.exes)
  171.     {
  172.         echo *** Missing EXE's \($missing.exes\\)
  173.     }
  174.     if (!sh_ok && !ls_ok) {
  175.         echo ***
  176.         echo *** Testing LS output format
  177.         test_ls_exe_ok
  178.     }
  179.     if (!sh_ok && !cat_ok) {
  180.         echo ***
  181.         echo *** Testing if CAT is really working
  182.         test_cat_exe_ok
  183.     }
  184.  
  185.     if (missing.dlls) {
  186.         echo ***
  187.         echo *** Some of DLL files requred are not found on LIBPATH.
  188.         echo ***
  189.         echo *** EMX*.DLL (emx runtime) can be downloaded from hobbes
  190.         echo *** ftp site ftp://hobbes.nmsu.edu/os2/unix/emx09a/emxrt.zip
  191.         echo ***
  192.         echo *** GNU*.DLL (runtime for GNU Utilites) are included with IrcII/OS2
  193.         echo *** in DLL subdirectory. Edit your CONFIG.SYS and add x:\\ircii\\dll to
  194.         echo *** LIBPATH, reboot after that.
  195.     }
  196.     if (missing.exes)
  197.     {
  198.         echo ***
  199.         echo *** Some of .EXE files requred are not found on the PATH. All needed .EXE 
  200.                 echo *** files are included with Ircii/OS2 in BIN subdirectory. Edit your 
  201.         echo *** CONFIG.SYS file and make sure that x:\\ircii\\bin is in the PATH.
  202.         echo ***
  203.         echo *** You will also need to add x:\\ircii\\dll to a LIBPATH in CONFIG.SYS, 
  204.                 echo *** it contains needed DLL's. Also all unix utilites are using EMX runtime
  205.                 echo *** DLL's. These DLL's also should be on a LIBPATH. EMX can be downloaded 
  206.         echo *** from ftp://hobbes.nmsu.edu/os2/unix/emxrt.zip
  207.     }
  208. }
  209.  
  210. run_all_tests
  211.  
  212. ^eval ^set novice $old_novice
  213. ^assign -old_novice
  214. ^assign -missing.dlls
  215. ^assign -missing.exes
  216. ^alias -run_exe
  217. ^alias -run_all_tests
  218. ^alias -test_ls_exe_ok 
  219. ^alias -test_cat_exe_ok
  220.  
  221.  
  222.