Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

test os type

0 views
Skip to first unread message

Jerry Jaskierny

unread,
Mar 31, 2001, 11:34:28 AM3/31/01
to
i'm trying to write a simple shell script that will output the OS type.
does anyone know of a better way other than to just check uname?

Markus Kliegl

unread,
Mar 31, 2001, 7:14:30 PM3/31/01
to
jask...@fscked.org (Jerry Jaskierny) writes:

> i'm trying to write a simple shell script that will output the OS type.
> does anyone know of a better way other than to just check uname?

No, uname seems to be the right solution, as uname(2) is the POSIX
function that gets all the info on a lower level and uname(1)
obviously uses uname :-)

--
Markus Kliegl

Jens Schweikhardt

unread,
Apr 2, 2001, 2:17:42 AM4/2/01
to
Jerry Jaskierny <jask...@fscked.org> wrote
in <slrn9cc2a6....@eddie.ce.mediaone.net>:
#
# i'm trying to write a simple shell script that will output the OS type.
# does anyone know of a better way other than to just check uname?

No, uname -s is as portable as it gets (it's POSIX). What's wrong with it?

sje2bk@bk4957:~ $ uname -s
FreeBSD
sje2bk@bkrfsf:~ $ uname -s
SunOS
sje2bk@bkrfsr:~ $ uname -s
Linux

Use uname -sr if you also need a revision number.

Regards,

Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

Keith Thompson

unread,
Apr 2, 2001, 7:04:50 AM4/2/01
to
jask...@fscked.org (Jerry Jaskierny) writes:
> i'm trying to write a simple shell script that will output the OS type.
> does anyone know of a better way other than to just check uname?

Depending on the level of detail you want, you might try the GNU
"config.guess" script, available at
<ftp://ftp.gnu.org/gnu/config/config.guess>
and various mirrors.

The current version is 1368 lines long. It prints something like
"sparc-sun-solaris2.7", "powerpc-ibm-aix4.3.3.0", "i586-pc-linux-gnu",
etc. (Yes, it's really Solaris 7, not Solaris 2.7, but uniqueness is
the point.)

Yes, it's pretty big, but consider whether 10 lines that you have to
write is better than 1368 lines that someone else has already written.

--
Keith Thompson (The_Other_Keith) k...@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Cxiuj via bazo apartenas ni.

Michael Wang

unread,
Apr 2, 2001, 11:28:10 PM4/2/01
to
>Depending on the level of detail you want, you might try the GNU
>"config.guess" script, available at
> <ftp://ftp.gnu.org/gnu/config/config.guess>
>and various mirrors.

[julie:/usr/local/bin]./config.guess
./config.guess: dummy-19693.c: cannot create

The bug has not been fixed although I have reported long time ago.

Posted to comp.unix.shell and emailed to config-...@gnu.org.

Keith Thompson

unread,
Apr 5, 2001, 4:36:49 AM4/5/01
to

Yes, I recently reported that same bug myself. It shows up if you run
it in a directory in which you can't create files.

Apparently there isn't a good portable solution. config.guess runs on
a *very* wide variety of systems; it can't even assume that it can
write files into /tmp.

0 new messages