AUUGN on the Web - Volume 16, Number 1:

UNIX Tricks & Traps

Series editor: Janet Jackson < Janet@dialix.oz.au >


Consistent Binary Support for Multiple Architectures Across a Common Filesystem

David Leonard < D.Leonard@fnarg.net.au >

A trick I picked up from Scott Merillees has come in infinitely useful over the last few years, especially since I have been working in an NFSed environment on (and off) about five or six different platforms.

Most of us have a personal ~/bin directory, maybe even a ~/lib (and some even have our own ~/etc !) If your ~/bin contains a binary compiled, under (say) HP/UX, then it more than likely won't work when you move over to your Alpha.

The blindingly simple and obvious solution to this problem is outlined as follows: compile your binary for each architecture, place in an architecture dependent directory and correct your search PATH at login.

The uname(1) program can give you the machine architecture , as well as the operating system name , and version , which you can then use to form your PATH environment variable. uname is found on virtually all UNIXes these days; and even if it's not, you could quickly write your own. For example:

$ uname -m; uname -s; uname -r mac68k NetBSD 1.0 $ PATH=$PATH:$HOME/bin/arch/`uname -m`; export PATH Or, to be really over the top:

$ PATH="$PATH:$HOME/bin/arch/`uname -m`/`uname -s`/`uname -r`" $ export PATH My environments are not that aggressive, so only a single depth ~/bin/arch satisfies my needs. This directory contains further subdirectories alpha, RISC, sun4 and mac68k. Sun's uname -m sometimes returns sun4c or sun4m but you can get around this with appropriate symbolic links.

For example, I have hunt(6) compiled for three architectures:

48 /home/leonard/bin/arch/alpha/hunt* 92 /home/leonard/bin/arch/RISC/hunt* 80 /home/leonard/bin/arch/mac68k/hunt*

For sites that have NIS netgroups containing users

Tim Cook < tim@deakin.edu.au >

The following program tells you what netgroups you (or other users) are in.

#!/bin/sh # netgroups - Like groups(1), but for netgroups # # $Id: unixTT.html,v 1.1 2002/07/29 04:51:29 benjsc Exp $ # $Source: /src/usr/local/bin/netgroups/netgroups,v $ # prog="netgroups" PATH=/bin:/usr/bin:/usr/ucb ; export PATH case $# in 0 ) ;; 1 ) USER="$1" ;; * ) echo "usage: $prog [USER]" 1>&2 ; exit 1 ;; esac case "$USER" in USER="`whoami 2>/dev/null`" ;; esac case "$USER" in echo "$prog: who are you?" 1>&2 ; exit 1 ;; esac ypmatch "$USER"."*" netgroup.byuser | sed 's/,/ /g'
Please send your contributions for this column to the Unix Tricks & Traps / User Support Mailbox Sub-editor, Janet Jackson < janet@dialix.oz.au > , phone/fax (09) 272 5061. Suggestions for topics are also welcome.


[Previous
article] [Contents] [Next article]

[Home
page]