#!/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>&nbsp;</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 &#0169; 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.