Click to See Complete Forum and Search --> : Discovering what OS in Bash


tecknophreak
07-22-2008, 11:57 PM
I'm running MSYS and Mingw32 on a Windows PC. Is there a way in bash that I can figure out what os is running? With C/C++, etc, I have the precompiler to handle that, I just don't know what will work with bash.

i845_
07-23-2008, 02:55 AM
Does uname -s work?

saikee
07-23-2008, 07:11 AM
Think
uname -a
or
uname -o
gives a little bit info.

Most distros modify the kernel and so the kernel name, from "uname -a", may give away the Linux identity.

happybunny
07-23-2008, 09:41 AM
more /etc/issue?

infiniphunk
07-23-2008, 12:09 PM
Unless I'm mistaken dmesg | more

should show some distro-specific info in the first few lines. try it.

bwkaz
07-23-2008, 07:11 PM
echo $MACHTYPE

will print the target-triplet (which is usually four items long on Linux) that bash was compiled for. ($MACHTYPE in general expands to bash's target triplet.) There are some cases where that doesn't match your actual system, but I think they're rare. They involve cross-compiling, which I doubt is what you're doing here. Or at least, they involve running a cross-compiled bash from inside the host computer's OS, which generally isn't possible unless the target is compatible with the host. If you run a cross-compiled bash (like e.g. the MSYS one) from within a system that's also cross-compiled, it's not going to lie.

You can also grab a recent config.guess script from automake, and run it. It will print the same target triplet (in fact config.guess is what was used to generate bash's $MACHTYPE built-in variable, when bash was compiled).

irlandes
07-25-2008, 12:12 PM
lsb_release -a

works on Kubuntu, not sure what has to be there to make it work.

For details, see man page.

irlandes
08-06-2008, 08:35 PM
cat /etc/issue