* Portable startup files question..
@ 1995-05-21 4:00 Ricardo Marek
1995-05-21 4:00 ` Uwe Leinberger
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Ricardo Marek @ 1995-05-21 4:00 UTC (permalink / raw)
How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc)
in order to get arround with the differences between OS types. (setting paths,
environment vars, aliases, etc..), having also the possibility of seting particular
stuff for a certain machine/host/OS System?
- Using `uname` is not the short way, because SunOS and Solaris have the same
identification.
- Using tcsh $OSTYPE is not portable in machines that doesn't have tcsh..
Any hint for startup files using SunOS 4.*, Solaris 2.*, Ultrix, HPUX, AIX
with the account, but logging in in different machines?
PLEASE ANSWER VIA E-MAIL To: ricky@fibronics.co.il
--- Ricky Marek.
\||/
+------------------------------------------------------------+ | @___oo
| Software Engineer in R&D Dpt. | / (__,,,,|
| Fibronics Ltd., Matam Industrial Park, Haifa 31905, Israel |^\/ _)
| Phone : +972-4-313690 E-mail: ricky@fibronics.co.il |/ _)
| Fax: +972-4-313342 http://www.fibronics.co.il/~ricky/ | / _)
+------------------------------------------------------------+ | )_)
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Portable startup files question.. 1995-05-21 4:00 Portable startup files question Ricardo Marek @ 1995-05-21 4:00 ` Uwe Leinberger 1995-05-22 4:00 ` Ido Sarig 1995-05-21 4:00 ` tim werner ` (2 subsequent siblings) 3 siblings, 1 reply; 13+ messages in thread From: Uwe Leinberger @ 1995-05-21 4:00 UTC (permalink / raw) In article <D8xA28.L5n@fibronics.co.il>, ricky@fibronics.co.il (Ricardo Marek) writes: >How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc) >in order to get arround with the differences between OS types. (setting >paths, >environment vars, aliases, etc..), having also the possibility of seting >particular >stuff for a certain machine/host/OS System? > >- Using `uname` is not the short way, because SunOS and Solaris have the >same > identification. > >- Using tcsh $OSTYPE is not portable in machines that doesn't have tcsh.. > >Any hint for startup files using SunOS 4.*, Solaris 2.*, Ultrix, HPUX, AIX >with the account, but logging in in different machines? > >PLEASE ANSWER VIA E-MAIL To: ricky@fibronics.co.il > >--- Ricky Marek. > \||/ >+------------------------------------------------------------+ | >@___oo >| Software Engineer in R&D Dpt. | / >(__,,,,| >| Fibronics Ltd., Matam Industrial Park, Haifa 31905, Israel |^\/ _) >| Phone : +972-4-313690 E-mail: ricky@fibronics.co.il |/ _) >| Fax: +972-4-313342 http://www.fibronics.co.il/~ricky/ | / _) >+------------------------------------------------------------+ | )_) > > > > > > Oh yeaahhhhhh, the wonders of UNIX compatibility !!!! And "Hi" to all the jerks always telling everybody: "You know one UNIX, you know all UNIXes!" Uwe ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-21 4:00 ` Uwe Leinberger @ 1995-05-22 4:00 ` Ido Sarig 1995-05-22 4:00 ` Guy Harris ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Ido Sarig @ 1995-05-22 4:00 UTC (permalink / raw) leinberger@axp621.gsi.de (Uwe Leinberger) wrote: > >In article <D8xA28.L5n@fibronics.co.il>, ricky@fibronics.co.il (Ricardo >Marek) writes: >>How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc) >>in order to get arround with the differences between OS types. (setting >>paths, >>environment vars, aliases, etc..), having also the possibility of seting >>particular >>stuff for a certain machine/host/OS System? >> >>- Using `uname` is not the short way, because SunOS and Solaris have the >>same >> identification. No they don't. Use `uname -a` and a simple awk script to get the 3rd field of the output, which is 4.x on SunOS and 5.x on Solaris. ------------------------------------------------------------ Ido Sarig | Phone: (+972) - 3 - 5388846 XRunner Project Manager | Fax: (+972) - 3 - 5331617 Mercury Interactive Corp. | | E-mail: ido@mercury.co.il ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-22 4:00 ` Ido Sarig @ 1995-05-22 4:00 ` Guy Harris 1995-05-24 4:00 ` Dale DePriest 1995-06-02 4:00 ` Christopher Samuel 2 siblings, 0 replies; 13+ messages in thread From: Guy Harris @ 1995-05-22 4:00 UTC (permalink / raw) Ido Sarig <ido> wrote: >No they don't. Use `uname -a` and a simple awk script to get the 3rd field >of the output, which is 4.x on SunOS and 5.x on Solaris. Use "uname -r" and *no* script, "awk" or otherwise, to get the version number of the OS, which is 4.x in SunOS 4.x (including 4.1.x, the OS component of Solaris 1.y) and 5.x in SunOS 5.x (the OS component of Solaris 2.x). "uname" can be told to print particular values; you're not obliged to get it to print all its values and use an "awk" or "sed" or whatever script to select one of them. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-22 4:00 ` Ido Sarig 1995-05-22 4:00 ` Guy Harris @ 1995-05-24 4:00 ` Dale DePriest 1995-05-25 4:00 ` Guy Harris 1995-06-02 4:00 ` Christopher Samuel 2 siblings, 1 reply; 13+ messages in thread From: Dale DePriest @ 1995-05-24 4:00 UTC (permalink / raw) In article <3pqfbf$ds0@elron2.elron.net>, Ido Sarig <ido> writes: |> leinberger@axp621.gsi.de (Uwe Leinberger) wrote: |> > |> >In article <D8xA28.L5n@fibronics.co.il>, ricky@fibronics.co.il (Ricardo |> >Marek) writes: |> >>How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc) |> >>in order to get arround with the differences between OS types. (setting |> >>paths, |> >>environment vars, aliases, etc..), having also the possibility of seting |> >>particular |> >>stuff for a certain machine/host/OS System? |> >> |> >>- Using `uname` is not the short way, because SunOS and Solaris have the |> >>same |> >> identification. |> |> |> No they don't. Use `uname -a` and a simple awk script to get the 3rd field |> of the output, which is 4.x on SunOS and 5.x on Solaris. |> |> |> ------------------------------------------------------------ |> Ido Sarig | Phone: (+972) - 3 - 5388846 |> XRunner Project Manager | Fax: (+972) - 3 - 5331617 |> Mercury Interactive Corp. | |> | E-mail: ido@mercury.co.il |> Here is how I do it: Note that I have had uname return two words on some machines. case `uname | awk '{print $1}'` in SunOS) if [ -f /bin/arch ] then ARCH=`arch` else ARCH=sun4v fi Other machines may need a similar treatment for example: ULTRIX) case `uname -m` in RISC) ARCH=decds;; VAX) ARCH=vax;; *) ARCH=deca;; esac -- _ _ Dale DePriest San Jose, California /`) _ // daled@Cadence.COM voice: (408) 428-5249 o/_/ (_(_X_(` fax: (408) 943-0402 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-24 4:00 ` Dale DePriest @ 1995-05-25 4:00 ` Guy Harris 1995-05-26 4:00 ` Thanh Ma 0 siblings, 1 reply; 13+ messages in thread From: Guy Harris @ 1995-05-25 4:00 UTC (permalink / raw) Dale DePriest <daled@cds9172.Cadence.COM> 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` ;; # # Insert stuff for your OS here. # esac ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-25 4:00 ` Guy Harris @ 1995-05-26 4:00 ` Thanh Ma 1995-05-26 4:00 ` Guy Harris 0 siblings, 1 reply; 13+ messages in thread From: Thanh Ma @ 1995-05-26 4:00 UTC (permalink / raw) guy@netapp.com (Guy Harris) writes: >Dale DePriest <daled@cds9172.Cadence.COM> 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-26 4:00 ` Thanh Ma @ 1995-05-26 4:00 ` Guy Harris 0 siblings, 0 replies; 13+ messages in thread From: Guy Harris @ 1995-05-26 4:00 UTC (permalink / raw) [followups to "comp.unix.shell", as that's probably the group in which this is most appropriate] Thanh Ma <tma@encore.com> wrote: [unnecessarily-included copy of the entire previous posting deleted] >$ uname -s >UNIX_SV >$ uname -n >infcons >$ uname -r >4.2MP >$ uname -v >2.01 >$ uname -m >i386 >$ uname -p >x86at I.e., "uname -m" gives the instruction-set architecture, but "uname -p" gives some indication of the type of machine - if "x86at" means "x86-instruction-set-architecture-based machine remotely descended from the IBM PC/AT", i.e. "IBM-compatible PC", then I guess it counts as the "kernel architecture". I *thought* I'd remembered that x86 SVR4 swapped "uname -m" and "uname -p" from what at least some other flavors of SVR4 (e.g., SunOS 5.x) did on non-x86 platforms; alas, it appears I was correct. Sigh.... I suspect SunOS 5.x on IBM-compatible PC's does as other SVR4-flavored UNIXes do; if so, then the cases for SunOS 5.x, and for "UNIX_SV", should do something such as check whether "uname -m" is "i386" and, if so, use *that* as the architecture, and otherwise use "uname -p" - unless, of course, SVR4s on some *other* platforms act like x86 SVR4 rather than other SVR4's. Note that BSD/OS 1.1 doesn't support "uname -p", but has a "uname -m" that produces "i386", so it'd fall into the same category: % uname -p uname: illegal option -- p usage: uname [-snrvma] % uname -m i386 % uname -s BSD/386 (BSD/OS 1.x was called "BSD/386" as it was PC-only; 2.x may get a port to some SPARC machines and possibly others, and may call itself "BSD/OS"). However, on at least one Linux system, "uname -m" appears to say what *flavor* of x86 chip you have, rather than that you have a chip that supports the 32-bit version of the x86 architecture by saying "i386", so on Linux (on which, at least one Linux system, "uname -s" prints "Linux"), you have to handle "i586" and probably "i486" and map them to "i386" (unless you really give a damn about the tiny additions the 486 and Pentium made to the user-mode instruction set). At times, I want to send the folks who did "uname" commands and "uname()" calls on various flavors of Unix to the penal colony in Kafka's "In the Penal Colony", and set the machine to carve "give 'uname' an option to print out the ABI/instruction set architecture" into their backs.... (And, no, POSIX doesn't help. 1003.2-1992 says "uname -m" should "Write the name of the hardware type on which the system is running to standard output", but I don't see any mention of "hardware type" in the index, so I suspect they don't define it - probably so no system would actually have to fix its behavior, even if that renders "uname -m" not convenient to use in, oh, say, a *PORTABLE STARTUP SCRIPT* such as the original poster wanted. 1003.1b-1993 says pretty much the same thing for "uname()".) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-22 4:00 ` Ido Sarig 1995-05-22 4:00 ` Guy Harris 1995-05-24 4:00 ` Dale DePriest @ 1995-06-02 4:00 ` Christopher Samuel 2 siblings, 0 replies; 13+ messages in thread From: Christopher Samuel @ 1995-06-02 4:00 UTC (permalink / raw) /* Followups redirected to comp.unix.admin */ In article <3pqfbf$ds0@elron2.elron.net> of comp.unix.admin, Ido Sarig <ido> doodled: ^^^ /* awooga awooga - broken news software alert :-) */ > No they don't. Use `uname -a` and a simple awk script to get the 3rd field > of the output, which is 4.x on SunOS and 5.x on Solaris. Remember that not all systems have uname, for example NeXTstep has it missing (although it does have the uname(2) call in it's POSIX libraries). Also remember that not all systems uname work the same way, for instance SCO's returns the hostname for "uname -s" whereas the rest of the world seems to return the operating system name (typical really). cheers, Chris -- Christopher Samuel, Open Software Systems Group, chris@rivers.dra.hmg.gb N-115, Defence Research Agency, St Andrews Road, Great Malvern, England, UK DISCLAIMER: I write only for myself, not for DRA. Phone: +44 1684 894644 "You can't write space opera in a vacuum" --- Iain Banks ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-21 4:00 Portable startup files question Ricardo Marek 1995-05-21 4:00 ` Uwe Leinberger @ 1995-05-21 4:00 ` tim werner 1995-05-22 4:00 ` Guy Harris 1995-05-23 4:00 ` Larry Gale 1995-05-26 4:00 ` Syed Zaeem Hosain 3 siblings, 1 reply; 13+ messages in thread From: tim werner @ 1995-05-21 4:00 UTC (permalink / raw) To: Ricardo Marek >From: ricky@fibronics.co.il (Ricardo Marek) >Date: Sun, 21 May 1995 09:55:35 GMT >How can I configure my startup files ( .cshrc, .login, .profile, >.tcshrc) in order to get arround with the differences between OS >types. (setting paths, environment vars, aliases, etc..), having also >the possibility of seting particular stuff for a certain >machine/host/OS System? > >- Using `uname` is not the short way, because SunOS and Solaris have >the same identification. This is not true. For me, "uname -r" will return "5.4" for Solaris, and "4.1.3" for SunOS, "A.09.04" for HP-UX. You can have a .profile thus: TCSH=/usr/local/bin/tcsh if test -x $TCSH ; then exec $TCSH ; fi You can put something like this in your .cshrc, in case your chsh is csh because not all the machines you log into have tcsh: if ( $?term ) then set TCSH = /usr/local/bin/tcsh if ( ! $?MYSHELL && -x $TCSH) then setenv MYSHELL $TCSH exec $TCSH -l endif endif set whatos = `uname -r | sed 's/\..*//'` if ( "$whatos" == 5 ) then # Solaris else if ( "$whatos" == 4 ) then # SunOS or Ultrix endif else # HP-UX endif YMMV hth, tw -- The shadow of the bamboo sweeps the steps, but the dust does not stir. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-21 4:00 ` tim werner @ 1995-05-22 4:00 ` Guy Harris 0 siblings, 0 replies; 13+ messages in thread From: Guy Harris @ 1995-05-22 4:00 UTC (permalink / raw) tim werner <werner@farina.mc.ab.com> wrote: >You can put something like this in your .cshrc, in case your chsh is >csh because not all the machines you log into have tcsh: Also, note that "uname -s" will give you the "name" of the OS, which would presumably let you, for example: > else if ( "$whatos" == 4 ) then > # SunOS or Ultrix > endif distinguish between SunOS 4.x and Ultrix in this case (I rather doubt that "uname -s" on Ultrix says "SunOS"). The way I tend to do it is to first switch on the value of "uname -s" and, if the version number of the OS matters - e.g., in order to distinguish between SunOS 4.x and SunOS 5.x - look at the value of "uname -r". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-21 4:00 Portable startup files question Ricardo Marek 1995-05-21 4:00 ` Uwe Leinberger 1995-05-21 4:00 ` tim werner @ 1995-05-23 4:00 ` Larry Gale 1995-05-26 4:00 ` Syed Zaeem Hosain 3 siblings, 0 replies; 13+ messages in thread From: Larry Gale @ 1995-05-23 4:00 UTC (permalink / raw) In article <D8xA28.L5n@fibronics.co.il>, ricky@fibronics.co.il (Ricardo Marek) says: > >How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc) >in order to get arround with the differences between OS types. (setting paths, >environment vars, aliases, etc..), having also the possibility of seting particular >stuff for a certain machine/host/OS System? > >- Using `uname` is not the short way, because SunOS and Solaris have the same > identification. > >- Using tcsh $OSTYPE is not portable in machines that doesn't have tcsh.. > >Any hint for startup files using SunOS 4.*, Solaris 2.*, Ultrix, HPUX, AIX >with the account, but logging in in different machines? > >PLEASE ANSWER VIA E-MAIL To: ricky@fibronics.co.il > >--- Ricky Marek. I don't know about the other systems, but 'uname -a' allows you to distinguish between SunOS (4.n.n) and Solaris (5.n) by looking at the 3rd field returned by the command. We use that mechanism locally with multiple Suns running different releases of the OS. -- Larry =========================================================================== + + + Larry Gale Systems Engineer + + gale@grace.musc.edu Clinical Support Systems + + (803)-792-6002 (voice) Center for Computing & Information Technology + + (803)-792-8319 (fax) Medical University of South Carolina + + 171 Ashley Avenue + + Charleston, SC 29425 + + + =========================================================================== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Portable startup files question.. 1995-05-21 4:00 Portable startup files question Ricardo Marek ` (2 preceding siblings ...) 1995-05-23 4:00 ` Larry Gale @ 1995-05-26 4:00 ` Syed Zaeem Hosain 3 siblings, 0 replies; 13+ messages in thread From: Syed Zaeem Hosain @ 1995-05-26 4:00 UTC (permalink / raw) In article <D8xA28.L5n@fibronics.co.il>, ricky@fibronics.co.il (Ricardo Marek) writes: >How can I configure my startup files ( .cshrc, .login, .profile, .tcshrc) >in order to get arround with the differences between OS types. (setting paths, >environment vars, aliases, etc..), having also the possibility of seting particular >stuff for a certain machine/host/OS System? > >- Using `uname` is not the short way, because SunOS and Solaris have the same > identification. > >- Using tcsh $OSTYPE is not portable in machines that doesn't have tcsh.. > >Any hint for startup files using SunOS 4.*, Solaris 2.*, Ultrix, HPUX, AIX >with the account, but logging in in different machines? > >PLEASE ANSWER VIA E-MAIL To: ricky@fibronics.co.il Here is some of the very first lines in my .cshrc that allows me to deal with a similar problem. It is kludgey for sure, but it works for me and I do not have the time to change it: #!/bin/csh # # Set up some window environment variables: # set osbase = `uname` if ( $osbase == "SunOS" ) then set osver = `uname -r` if ( $osver == "4.1.3_U1revB" || $osver == "4.1.3_U1" || $osver == "4.1.3C" ) then set osver = "4.1.3" endif if ( $osver == "4.1.1" || $osver == "4.1.2" || $osver == "4.1.3" || $osver == "4.1.4" ) then set architecture = `/usr/bin/arch` set system = `/usr/bin/hostname` else if ( $osver == "5.0" || $osver == "5.1" || $osver == "5.2" || $osver == "5.3" || $osver == "5.4" ) then set architecture = `/usr/ucb/arch` set system = `/usr/ucb/hostname` else echo "Unknown osver = $osver" set system = "UNKNOWN" endif else if ( $osbase == "HP-UX" ) then set architecture = "hp" set system = `/bin/hostname` else if ( $osbase == "IRIX" ) then set architecture = "mips" set system = `uname -a | awk '{print $2}'` endif And after this code runs, I use "osbase", "architecture" and "system" later in the file to decide what to do (paths, environment vars, etc.). For example: # # OpenWindows environment variable: # if ( $osbase == "SunOS" ) then setenv OPENWINHOME /usr/openwin if (! $?CEPATH ) then setenv CEPATH "$HOME/.cetables:/etc/cetables:$OPENWINHOME/lib/cetables" endif set winpath = ($OPENWINHOME/bin $OPENWINHOME/bin/xview $OPENWINHOME/demo) else set winpath = () endif Note that some of the above are long lines and may wrap funny in your News reader. Sorry about that. Z -- ------------------------------------------------------------------------- | Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 | | Z Consulting Group San Jose, CA 95161 szh@zcon.com | ------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~1995-06-02 4:00 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1995-05-21 4:00 Portable startup files question Ricardo Marek 1995-05-21 4:00 ` Uwe Leinberger 1995-05-22 4:00 ` Ido Sarig 1995-05-22 4:00 ` Guy Harris 1995-05-24 4:00 ` Dale DePriest 1995-05-25 4:00 ` Guy Harris 1995-05-26 4:00 ` Thanh Ma 1995-05-26 4:00 ` Guy Harris 1995-06-02 4:00 ` Christopher Samuel 1995-05-21 4:00 ` tim werner 1995-05-22 4:00 ` Guy Harris 1995-05-23 4:00 ` Larry Gale 1995-05-26 4:00 ` Syed Zaeem Hosain
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox