Question about SunOS version, how to include in C source


 
Thread Tools Search this Thread
Operating Systems Solaris Question about SunOS version, how to include in C source
# 1  
Old 01-10-2012
Question about SunOS version, how to include in C source

Sorry if here is the wrong place to put this question, but for college we develop small programs in C using Solaris. Most of time is OK for us not to document nothing, until now.

Every time program is executed must print OS name.

Does Solaris has some predefined macros which I can include in my source.

For example

Code:
printf("OS: %s \n", __os__);

with result

Code:
SunOS 5.11

I found __'System'_'Version' , but it doesn' t work
# 2  
Old 01-10-2012
use uname it will give you the OS details along with other details


$ uname -a
CYGWIN_NT-5.1 venkat-LXP 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin
# 3  
Old 01-14-2012
This will print OS information on which is run. I need to incorporate that using macro.
# 4  
Old 01-14-2012
This code:
Code:
#include <sys/utsname.h>

main()
{
   struct utsname name;
   uname(&name);
   printf("%s %s\n",name.sysname,name.release);
}

will output:
Code:
SunOS 5.11

This User Gave Thanks to jlliagre For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How do I remove or hide SunOS version/release from remote login prompt?

For any SunOS 5.XX release, it appears prior to the "login:" prompt (as if a "uname" command is run). Would anyone know where that initial display of SunOS release comes from upon a remote login and how I can stop if from displaying? Thank you (4 Replies)
Discussion started by: ssid61
4 Replies

2. UNIX for Advanced & Expert Users

SunOS - version upgrade - Control Characters

Hi, We have a scenario of OS upgrade and in a simialr upgrade last time, we noticed a few stray bytes appearing and it resulted in application programs failing..... Could you please share your expertise in removing such control characters in input/output files, to keep the ball rolling in... (1 Reply)
Discussion started by: ab_2010
1 Replies

3. Solaris

Java / SunOS Security question

Hi, I have a question about the Java that comes with the Solaris 9/10 OS. All my boxes are servers, only ssh allowed, no x windows, hardened, firewaled, etc... Their purpose is Oracle DB's and Sun One Dir servers. None of which use the OS version of Java as far as know. Question IS, can... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

4. UNIX for Advanced & Expert Users

How do I find the version of Informatica, Cognos and DataStage on SUNOS 5.8

How do I find the version of Informatica, Cognos and DataStage using a unix command on my Unix machine SunOS 5.8. I don't want to use front end to find this information. (1 Reply)
Discussion started by: gram77
1 Replies

5. UNIX for Dummies Questions & Answers

SunOS basic question

Hello everybodyI have connected an external tape drive onto my Sun Spark station running Sun OS 4.1.3. since am in the basic elementary stage in Sun OS, can someone answer the below questions pls 1) after connecting the tape drive to a server and rebooting does /dev/st0 show up automatically?... (3 Replies)
Discussion started by: karthikosu
3 Replies

6. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies

7. UNIX for Dummies Questions & Answers

SunOS version 5.7 root password recovery?

I just received a Sun microsystem ultra 5 for a auction, it is running sunOS version 5.7, when it boots it asks for user login and password, I dont have either, is there a way to login in as root user with out the password or is there a way to recover the password so I can get in to my system? (1 Reply)
Discussion started by: mscav219
1 Replies

8. UNIX for Dummies Questions & Answers

What is the difference : SunOS & Solaris Version.

Sorry I think someone already pointed out this but I couldn't find it. Please tell me what is the difference between SunOS Version and Solaris Version. What is the purpose of maintaining these two things ? Thanks (2 Replies)
Discussion started by: champion
2 Replies
Login or Register to Ask a Question