From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1020c6,5120b503df4ed78f X-Google-Attributes: gid1020c6,public X-Google-Thread: 10b612,5120b503df4ed78f X-Google-Attributes: gid10b612,public X-Google-Thread: 1164f8,5120b503df4ed78f X-Google-Attributes: gid1164f8,public X-Google-Thread: 11035d,5120b503df4ed78f X-Google-Attributes: gid11035d,public X-Google-Thread: 1070f0,5120b503df4ed78f X-Google-Attributes: gid1070f0,public X-Google-Thread: 115614,5120b503df4ed78f X-Google-Attributes: gid115614,public X-Google-Thread: 1012a6,5120b503df4ed78f X-Google-Attributes: gid1012a6,public From: tma@encore.com (Thanh Ma) Subject: Re: Portable startup files question.. Date: 1995/05/26 Message-ID: X-Deja-AN: 103352791 distribution: inet sender: news@encore.com (Usenet readnews user id) references: <3pndb7$1670@rs18.hrz.th-darmstadt.de> <3pqfbf$ds0@elron2.elron.net> <3q2ikp$ju@nova.netapp.com> organization: Encore Computer Corporation newsgroups: comp.unix.solaris,comp.unix.ultrix,comp.unix.admin,comp.unix.shell,comp.unix.aix,comp.sys.sun.admin,comp.sys.dec guy@netapp.com (Guy Harris) writes: >Dale DePriest wrote: >>case `uname | awk '{print $1}'` in >>SunOS) if [ -f /bin/arch ] >> then ARCH=`arch` >> else ARCH=sun4v >> fi >Or, even better (tested on SunOS 4.1.3, SunOS 5.4, IRIX 5.3, and >DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX 3.0, Ultrix code taken from the >previous example): > # > # Don't waste time screwing around with "awk" just to get the > # name of the OS; use the standard "uname -s" flag. (The "awk" > # in the example was probably unnecessary in any case, as > # "uname" generally doesn't print *all* the various bits of > # information it can by default, you have to use "uname -a" to > # get that.) > # > # NOTE: on some older flavors of UNIX, "uname -s" interprets > # "system name" as "name of the machine" rather than "name of > # the OS" (for reasons that date back to the really dim dark > # ages of UNIX history); I think some SVR3.x systems do so, > # as well as older systems. > # > # To determine the flavor of the OS on *those* systems, you're on > # your own; piping the output of "uname" to "awk" probably won't > # help, because it'll print the machine name in any case. > # > # This example only sets ARCH to an indication of the instruction-set > # architecture of the machine; other UNIX-flavor-dependent stuff > # could be done as well. This means it does *not* set it to > # the output of the "arch" command in SunOS 4.1[.x], as that > # prints Sun's old "application architecture" name - i.e., "sun4" > # rather than "sparc" for SPARC machines. > # > # This is a Bourne-compatible-shell example. A C-shell-compatible > # version is left as an exercise to the reader. > # > # This only deals with the OSes I have on hand, plus Ultrix with > # code lifted from the posting to which I'm following up. > # Versions for other OSes are left as an exercise to the reader. > # > # The coding style is the one I use; changes to match your preferred > # Bourne-shell coding style are left as an exercise to the reader. > # > case `uname -s` in > SunOS) > case `uname -r` in > 4.1*) > # > # SunOS 4.1[.x] should have an "arch" command. > # It prints the "application architecture" > # of the machine, e.g. "sun4" for SPARC and, > # as I remember, "sun3" for 68K. > # > # If, for some reason, you give a damn about > # the "kernel architecture", use "arch -k", but > # you probably *don't* give a damn about it. > # > # For now, we map "sun4" to "sparc", and > # "sun3" to "m68k"; SunOS 5.x uses "sparc" > # rather than "sun4", as not all SPARC machines > # running 5.x - or 4.1[.x], for that matter! - > # are Sun machines, and I'm assuming "ARCH" here > # is supposed to mean "instruction-set architecture" > # in any case. > # > case `arch` in > sun4) > ARCH=sparc > ;; > sun3) > ARCH=m68k > ;; > *) > # > # There aren't any others - the 386i > # never ran 4.1[.x] - but default just > # in case. > # > ARCH=`arch` > ;; > esac > ;; > 5.*) > # > # In SunOS 5.x, at least on SPARC, the > # "application architecture" is printed by > # "uname -p". > # > # WARNING: the significance of "-m" and "-p" in > # various SVR4-flavored systems is not, as far > # as I know, consistent among all systems. In > # particular, on x86-based systems, "uname -p" > # may say what kind of x86 processor (386, 486, > # Pentium, etc.) the machine has, and "uname -m" > # may give the "application architecture" of "i386" > # (given that I suspect 99 44/100% of the x86-based > # machines running UNIX have a kernel architecture > # of "IBM-compatible PC", I don't know of any way > # to get the "kernel architecture"; anybody who > # has a Sequent Symmetry is welcome to indicate how > # one distinguishes them from PeeCees, in case > # anybody gives a damn - but, as per the section > # on SunOS 4.1[.x], I suspect nobody does). > # > # If anybody does happen to give a damn, on SPARC > # 5.x machines "uname -m" gives the kernel > # architecture. > # > ARCH=`uname -p` > ;; > esac > ;; > ULTRIX) > case `uname -m` in > RISC) > ARCH=decds > ;; > VAX) > ARCH=vax > ;; > *) > ARCH=deca > ;; > esac > ;; > OSF1) > # > # "OSF1" is here assumed to really mean "Digital UNIX"; > # we use "uname -m". I don't know whether DEC finally > # ended up porting OSF/1 or Digital UNIX of any flavor > # to any of their MIPS-based machines or not, nor do I > # know what any *other* flavors of OSF/1 do. > # > # On Alpha machines, "uname -m" returns "alpha". > # > ARCH=`uname -m` > ;; > IRIX) > # > # We deal only with IRIX 5.x here; if you have an earlier > # version, put the appropriate code here, after switching > # on "uname -r" if necessary. > # > # The man page claims that "uname -p" prints "the (informal) > # of the current system's instruction set architecture", > # so that's what we use for ARCH; it prints "mips". > # > # "-m" prints the CPU board type in 5.x. > # > ARCH=`uname -p` > ;; Unixware on Intel: $ uname -s UNIX_SV $ uname -n infcons $ uname -r 4.2MP $ uname -v 2.01 $ uname -m i386 $ uname -p x86at Thanh Ma tma@encore.com > # Insert stuff for your OS here. > # > esac