home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl_utl.zip / testperl.cmd < prev   
OS/2 REXX Batch file  |  1997-12-02  |  6KB  |  220 lines

  1. @echo off
  2.  
  3. rem: To use it, you can provide the name of Perl to check as a command arg,
  4. rem: as in
  5. rem      testperl perl_
  6.  
  7.  
  8. set tperl=%1
  9. if "%tperl%" == "" set tperl=perl
  10.  
  11. echo ====================================
  12. echo Testing %tperl%...  Getting version...
  13. echo ====================================
  14. rem Errorlevel is not set if the program is not found?!
  15. %tperl% -e "exit 1"
  16. if errorlevel 1 goto mayhave
  17. goto noperl
  18.  
  19. :mayhave
  20. %tperl% -v
  21. if errorlevel 1 goto noperl
  22. goto haveperl
  23.  
  24. :noperl
  25. echo Cannot start %tperl% !!!  Please check that you have %tperl% on PATH,
  26. echo and (if you do not use perl_.exe) that perl.dll is on LIBPATH.
  27. echo ... Keep in mind that changes to config.sys DO NOT take effect
  28. echo until reboot, and LIBPATH can be changed ONLY from config.sys.
  29. input "Press <ENTER>" %%i
  30. exit 1
  31.  
  32. :haveperl
  33. perl -S -x testperl.cmd
  34. exit 0
  35.  
  36. #! perl
  37.  
  38. sub get_help;
  39.  
  40. $| = 1;
  41. print <<EOP;
  42. ====================================
  43. We checked that Perl can be loaded.  Apparently, your PATH and LIBPATH 
  44. are set to reasonable values.  From now on the tests are coded in Perl.
  45. EOP
  46.  
  47. print "Press <ENTER>: ";
  48. <>;
  49. print <<EOP;
  50. ====================================
  51. The next step is to check that you installed shell in a location perl can 
  52. find, so that you can start external programs.
  53. EOP
  54. open SH, 'echo $SH_VERSION |' or $no_sh++;
  55. unless ($no_sh) {
  56.   chomp ($v = <SH>);
  57.   close SH or warn "Errors closing pipe from shell: \$!='$!', \$?=$?\n";
  58.   print "I could find your shell, its version is '$v'\n" if $v;
  59.   $no_sh++ unless $v;
  60. }
  61. if ($no_sh) {
  62.   print <<EOP;
  63. ====================================
  64. I could not find your shell.  You WILL have problems starting external
  65. programs (except the simplest ones).  Please check that you installed
  66. a shell with a Bourne syntax and informed Perl where to find it.
  67. EOP
  68.   if (exists $ENV{PERL_SH_DIR}) {
  69.     print <<EOP;
  70. ====================================
  71. You had set an environment variable PERL_SH_DIR. However,
  72. EOP
  73.     if (-d $ENV{PERL_SH_DIR}) {
  74.       print <<EOP;
  75. though there is a directory with name '$ENV{PERL_SH_DIR}',
  76. EOP
  77.       if (-f "$ENV{PERL_SH_DIR}/sh.exe") {
  78.     print <<EOP;
  79. and there is a file with name '$ENV{PERL_SH_DIR}/sh.exe', I could not 
  80. execute it!  This should not happen!  
  81. If this file is executable by hand, please report to 
  82.    ilya\@math.ohio-state.edu.
  83. Thanks.
  84. EOP
  85.       } else {
  86.     print <<EOP;
  87. there is NO FILE with name '$ENV{PERL_SH_DIR}/sh.exe' !
  88. EOP
  89.     get_help '"Starting OS/2"', 'PERL_SH_DIR';
  90.       }
  91.     } else {
  92.       print <<EOP;
  93. there is NO DIRECTORY with name '$ENV{PERL_SH_DIR}' !
  94. EOP
  95.       get_help '"Starting OS/2"', 'PERL_SH_DIR';
  96.     }
  97.   } else {
  98.     print <<EOP;
  99. You do not have PERL_SH_DIR set in your environment.
  100. EOP
  101.     get_help '"Starting OS/2"', 'PERL_SH_DIR';
  102.   }
  103. } else {
  104.   open SH, 'DDD_VERSION=716; echo $DDD_VERSION |' 
  105.     or $no_sh++;
  106.   chomp ($v = <SH>);
  107.   close SH or warn "Errors closing pipe from shell: \$!='$!', \$?=$?\n";
  108.   print <<EOP unless $v == 716;
  109. ====================================
  110.   Got '\$v=$v', expected '\$v=716' !
  111. Though a shell can be found, it does not follow Bourne shell conventions.
  112. Expect a lot of problems when starting external programs which expect Bourne
  113. shell semantics.
  114. EOP
  115. }
  116.  
  117. print "Press <ENTER>: ";
  118. <>;
  119.  
  120. print <<EOP;
  121. ====================================
  122. Ouph, the most frequent problem is behind...  Now testing Perl library search.
  123. EOP
  124.  
  125. eval 'use Config; 1' or $no_config++;
  126. if ($no_config) {
  127.   print <<EOP;
  128. Cannot find the core of Perl library.  If you have it installed:
  129. EOP
  130.   get_help "PERLLIB_PREFIX";
  131.   print <<EOP;
  132. Skipping further tests now...
  133. EOP
  134. } else {
  135.   print <<EOP;
  136. Found Perl library.  Fine...
  137. EOP
  138.   print "Press <ENTER>: ";
  139.   <>;
  140.  
  141.   $prefix = 'f:/perllib/';
  142.   if (exists $ENV{PERLLIB_PREFIX}) {
  143.     @parts = split /[ ;]/, $ENV{PERLLIB_PREFIX}, 2;
  144.     print <<EOP if @parts < 2;
  145. ====================================
  146. Malformed PERLLIB_PREFIX!  Two parts should be separated by SPACE or SEMICOLON!
  147. EOP
  148.     (substr $prefix, 0, (length $part[0])) = $part[1] 
  149.       if substr $prefix, 0, (length $part[0]) eq $part[0];
  150.   }
  151.   $prefix =~ s|/$||;
  152.   @f_keys = grep { $Config{$_} =~ /^(?!\Q$prefix\E\b\S*$)[a-z]:/i
  153.              and not /^(emxpath|libemx)$/} keys %Config;
  154.   foreach (@f_keys) {
  155.     next if 
  156.       /^(full_sed|libc|make|rsx|sh|strings|sysman|timeincl|usrinc)$/ 
  157.     and (-e $Config{$_} or -e "$Config{$_}.exe");
  158.     if ($_ eq 'libpth') {
  159.     $baddir = 0;
  160.     foreach $dir (split /\s+/, $Config{libpth}) {
  161.         $baddir++, last unless -d $dir;
  162.     }
  163.     next unless $baddir;
  164.     }
  165.     print <<EOP unless $have_bad++;
  166. ====================================
  167. The following entries in '$INC{'Config.pm'}' 
  168. contain path settings which look suspicious:
  169. EOP
  170.     print " $_ => '$Config{$_}'\n";
  171.   }
  172.   print <<EOP unless $have_bad;
  173. ====================================
  174. Path entries in '$INC{'Config.pm'}' look OK: either start 
  175. with reasonable prefix, or mention existing directories/files.
  176. EOP
  177.   print "Press <ENTER>: ";
  178.   <>;
  179.  
  180.   eval "use Net::Config; 1" or $no_netconfig++;
  181.   if ($no_netconfig) {
  182.     print <<EOP;
  183. ====================================
  184. You do not have Net::Config, so cannot have problems with it!  ;-)  OK...
  185. EOP
  186.   } elsif ($NetConfig{inet_domain} ne 'tusik.hip.berkeley.edu') {
  187.     print <<EOP;
  188. ====================================
  189. Apparently you edited '$INC{'Net/Config.pm'}', 
  190. so I expect you know what you did.  OK...
  191. EOP
  192.   } else {
  193.     print <<EOP;
  194. ====================================
  195. You DID NOT edit '$INC{'Net/Config.pm'}', 
  196. You may have a lot of problems with networking...  Please edit this file.
  197. EOP
  198.   }
  199. }
  200. print "Tests finished. Press <ENTER>: ";
  201. <>;
  202.  
  203. sub get_help {
  204.   print <<EOP;
  205. Consider getting help via
  206. EOP
  207.   foreach (@_) {
  208.     print <<EOP;
  209.      view perl $_
  210. EOP
  211.   }
  212.   print <<EOP;
  213. or in whatever way you like the Perl documentation accessed, say, via 
  214.   perldoc perlos2
  215. man, acrobat, netscape, lynx, GNU info, TeX, reading REAME.os2, reading
  216. POD files, and so on.
  217. EOP
  218. }
  219.  
  220.