I had the same problem and came across a solution
that gcc uses. For various reasons this is
expressed as a bash script and a more recent
version is probably abailable. I leave the conversion
to Perl as an exercise for the reader:
# Short circuit this function if we know which system we are on
if [ $OS_SYSTEM_REALLY ]; then
echo "${OS_SYSTEM_REALLY}"
return
fi
# First get the values for this machine
# Code lifted from config.guess in the gcc software
OS_UNAME_M=`(uname -m) 2>/dev/null` || OS_UNAME_M=unknown
OS_UNAME_S=`(uname -s) 2>/dev/null` || OS_UNAME_S=unknown
OS_UNAME_R=`(uname -r) 2>/dev/null` || OS_UNAME_R=unknown
OS_UNAME_V=`(uname -v) 2>/dev/null` || OS_UNAME_V=unknown
OS_UNAME="${OS_UNAME_M}:${OS_UNAME_S}:${OS_UNAME_R}:${OS_UNAME_V}"
# Note: order is significant - the case branches are not exclusive
+.
case "${OS_UNAME}" in
sun4*:SunOS:5.[012345]*:*)
echo "sol24"
return ;;
sun4*:SunOS:5.[6789]*:*)
echo "sol26"
return ;;
sun4*:SunOS:[7891]*:*)
echo "Unknown Solaris version" >&2
echo "Try setting \$OS_SYSTEM_REALLY to sol26" >&2
echo "unknown"
return ;;
sun4*:SunOS:*:*)
echo "sun"
return ;;
*:AIX:1:4)
echo "aix41"
return ;;
*:IRIX*:5.*:*)
echo "sgi"
return ;;
*:IRIX*:6.[2345]:*)
echo "irix62"
return ;;
9000/[78]??:HP-UX:*:*)
echo "hp"
return ;;
i[345678]86:Linux:*:*)
echo "linux"
return ;;
sparc:Linux:*:*)
echo "ulinux"
return ;;
*:*:*:*)
# If we get here then we have something weird
echo "Unknown system \"${OS_UNAME}\"" >&2
echo "Try setting \$OS_SYSTEM_REALLY to one of sun, sol, h
+p etc" >&2
echo "unknown"
return ;;
esac
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|