Just wanted to know - is there a standard path where uname is installed?
e.g. /usr/bin/uname
or /bin/uname
I'm asking with regards to HP-UX, AIX, SunOS and RedHat Linux
Is there a common path in which all of the above contain uname? If not, how can I know on which OS my script is executing?
uname
should be in a location that's in your$PATH
which almost always includes/bin
and/usr/bin
. You should be able to rely on executinguname
without specifying a full path.If you are making a general purpose script, you can include /usr/bin and /bin in the pathname if you are unsure. Then it would not matter.
You can never rely on binaries being in a particular location across all operating systems. Generally, for portability's sake, you will want to rely on the path being set properly. But safe programs tends to lock down the path (and Perl's taint mode modifies the path too). Thus perhaps offer the user of the script the ability to configure the binaries to be used.