I asked recently about using /etc/redhat-release and got some useful answers. My thanks to all who replied.
Now a slight variant:
Can anyone suggest some resource that a PROGRAM (compiled C program) can examine while running to find out what platform it is runninng on ?
Things that come to mind include: 1. output of uname to see if the kernel version contains "elX" where X is a digit, such as el4, el5, etc., identifying RHEL-4, RHEL-5, etc. 2. do the same thing by exmining the filename of the kernel (if I knew how to find the file for the currently running kernel, that is.
can anyone suggest any other checks I could do?
Thanks again!
On 07/01/2010 06:55 AM, Frank Murphy wrote:
cd /proc | cat version
$ cd /proc | cat version cat: version: No such file or directory $ ls /proc/version /proc/version $ cat /proc/version Linux version 2.6.34-git16.fc13.i686 (jd@localhost.localdomain) (gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) ) #3 PREEMPT Sun May 30 21:17:11 PDT 2010
On 01/07/10 16:56, JD wrote:
On 07/01/2010 06:55 AM, Frank Murphy wrote:
cd /proc | cat version
$ cd /proc | cat version cat: version: No such file or directory $ ls /proc/version /proc/version $ cat /proc/version Linux version 2.6.34-git16.fc13.i686 (jd@localhost.localdomain) (gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) ) #3 PREEMPT Sun May 30 21:17:11 PDT 2010
My mistake: $ cd /proc |cat version Linux version 2.6.33.5-124.fc13.i686.PAE (mockbuild@x86-11.phx2.fedoraproject.org) (gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) ) #1 SMP Fri Jun 11 09:42:24 UTC 2010
Patrick O'Callaghan wrote:
On Thu, 2010-07-01 at 17:02 +0100, Frank Murphy wrote:
My mistake: $ cd /proc |cat version
Or just 'cat proc/version'
better yet 'cat /proc/version'.
On Thu, 2010-07-01 at 17:02 +0100, Frank Murphy wrote:
My mistake: $ cd /proc |cat version Linux version 2.6.33.5-124.fc13.i686.PAE (mockbuild@x86-11.phx2.fedoraproject.org) (gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) ) #1 SMP Fri Jun 11 09:42:24 UTC 2010
I still don't see how you're getting that to work. If you had ; instead of | between the commands, then I could see it working.
$ cd /proc ;cat version Linux version 2.6.27.25-78.2.56.fc9.i686 (mockbuild@) (gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) ) #1 SMP Thu Jun 18 12:47:50 EDT 2009
But it still seems like far more messing around than's needed. If you want to read that file, simply do so.
i.e. cat /proc/version
I see no point in changing the current working directory to /proc.
On Thu, Jul 01, 2010 at 09:49:49 -0400, fred smith fredex@fcshome.stoneham.ma.us wrote:
Can anyone suggest some resource that a PROGRAM (compiled C program) can examine while running to find out what platform it is runninng on ?
You could look at the source for uname and see what it does.
can anyone suggest any other checks I could do?
What are you really trying to do? Normally you want to check to see if some feature is supported or an ABI versiob, not really a program version. Sometimes a program version makes a good proxy for those. It's hard to suggest something without knowing your higher level goal.
On 07/01/2010 09:49 AM, fred smith wrote:
I asked recently about using /etc/redhat-release and got some useful answers. My thanks to all who replied.
Now a slight variant:
Can anyone suggest some resource that a PROGRAM (compiled C program) can examine while running to find out what platform it is runninng on ?
Things that come to mind include:
- output of uname to see if the kernel version contains "elX" where X
is a digit, such as el4, el5, etc., identifying RHEL-4, RHEL-5, etc. 2. do the same thing by exmining the filename of the kernel (if I knew how to find the file for the currently running kernel, that is.
(1) There is a uname(2) system call that any C or C++ program can call that has all the information that the uname(1) command provides. Do a 'man 2 uname' for details.
(2) I'm not exactly sure how to get at the physical kernel file without first doing a uname, then matching that information with /boot/vmlinux-xxxx. /proc/versions can tell you more information, but not exactly the file name.