#!/bin/sh # (c) Christian Renz <crenz@web42.com? # http://www.web42.com/software/findperl/ ### Configuration ### # Add a path here (e.g. /usr/bin/locate) if you run into problems LOCATE=locate WHICH=which UNAME=uname GREP=grep # Shell-Expression for perl interpreter filenames (for locate) PERLSHEX='perl' # Regex for perl interpreter filenames (for grep) PERLREGEX='/perl[0-9.]*$' # perl interpreter filenames (for which and manual search) PERLNAMES='perl perl5 perl4' # Fallback paths if locate and which fail FALLBACK='/usr/bin /usr/local/bin /bin /opt/bin' # Error formatting RED='<font color="#C00000"><b>' NORED='</font></b>' ### Main Program ### # echo nice HTML layout echo 'Content-Type: text/html <html> <head> <title>findPerl</title> </head> <p> </p> <blockquote> <h2>findPerl</h2> <hr size="1" width="100%"> ' # find out some system information SYSINFO=`$UNAME -a` if [ -z "$SYSINFO" ]; then echo "<p>$RED No system information found: $UNAME failed $NORED </ +p>" else echo "<p><b>System information (retrieved using <tt>$UNAME</tt>)</ +b>: $SYSINFO</p>" fi ### Searching for Perl ### echo "<p>Searching for perl interpreters installed on your system. This may take a few seconds.</p><p>" # Using locate... METHOD="<tt>$LOCATE</tt> / <tt>$GREP</tt>" PERLFOUND=`$LOCATE "$PERLSHEX" | $GREP "$PERLREGEX"` # Using which... if [ -z "$PERLFOUND" ]; then echo "<p>$RED $METHOD failed. $NORED Using <tt>$WHICH</tt> instead +.<p>" METHOD="<tt>$WHICH</tt>" for i in $PERLNAMES; do # echo "Searching for '$i'...<br>" THISFOUND=`$WHICH $i` if [ "$THISFOUND" ]; then PERLFOUND="$PERLFOUND $THISFOUND" fi done fi # Using fallback paths... if [ -z "$PERLFOUND" ]; then echo "<p>$RED $METHOD failed. $NORED Using search in <tt>$FALLBACK +</tt> instead.</p>" METHOD="search in <tt>$FALLBACK</tt>" for i in $FALLBACK; do for j in $PERLNAMES; do PERLFOUND="$PERLFOUND $i/$j" done done fi ### Find real perl interpreters ### REALPERL='' # $PERLFOUND probably contains some paths, man pages etc. # We are only interested in those files which are standard # files and executable for i in $PERLFOUND; do if [ -f "$i" -a -x "$i" ]; then REALPERL="$REALPERL $i" fi done ### Output information about perl interpreters ### if [ -z "$REALPERL" ]; then echo "<p>$RED Sorry, I was unable to find any perl interpreter.$NORED Probably something went horribly wrong. Contact you +r server administrator for assistance.</p>" else echo "<p><b>perl interpreters found using $METHOD:</b><ul>" for i in $REALPERL; do if [ -f "$i" -a -x "$i" ]; then p=`$i -e 'print "$]<br>Library paths:<br> <font size=\"-1\"><tt>" . join("<br>", @INC) . "</font></tt>"'` echo "<li><b><tt>$i</tt></b><br>Version: $p</li>" fi done echo "</ul></p>" fi echo '<hr size="1" width="100%"> <font size="-1">findPerl 0.1 beta - Copyright © 2001 Christian R +enz - <a href="http://www.web42.com/software/findperl/">findPerl Homepage</a +></font> </blockquote>' ### eof ###
In reply to Find installed Perl interpreters (shell script!) by crenz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |