tags:

views:

1011

answers:

5

I want to be able to determine the output folder based on the platform name: AS3, AS4, AS5, SUN.

I couldn't figure out how to extract the platform name from the system. I experimented with:

uname -a

file /bin/bash

Thanks

Solution

./lsb_release -a

Kudos to Paul Dixon

+2  A: 

I think you'll have to look in a specific file for each OS. For example, on SunOS, you can type:

uname -s -r -v

For RHEL, check /etc/issue.

David Grant
+2  A: 

Some linux systems will have support for lsb_release

Paul Dixon
+1  A: 

You can include sys/utsname.h to get OS information on Unix platforms.

struct utsname buf;
uname(&buf);
cout << buf.sysname << endl;

This will at least give you the name of the platform. I'm not sure what you mean by "output folder", so I'm not sure what you need to do after that.

Bill the Lizard
It prints Linux, I need it to print AS3 or AS4 or AS5 -- it there a way to determine that?Thanks
A: 

It looks like you want (at least in part) the release number. On Red Hat, you can get the release like this:

> cat /etc/redhat-release 
CentOS release 4.3 (Final)
Red Hat Enterprise Linux WS release 4 (Nahant Update 4)

A lot of other Linux distributions have their own files in /etc that give release numbers, too:

  • /etc/redhat-release
  • /etc/SuSE-release
  • /etc/ubuntu-release
  • /etc/fedora-release

etc.

tgamblin
A: 

In the past (pre-Linux even) I've found /bin/arch to be reasonably common across Unix systems and useful for getting some information about your hardware platform. (On Linux it returns the same as uname -m).

timday