473,671 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

determine operating system

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)
Thanks,

Kevin
Jul 22 '05 #1
27 6781
Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


Short answer: no

Long answer: no
Jul 22 '05 #2
Julie <ju***@nospam.c om> wrote in news:40******** *******@nospam. com:
Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


Short answer: no

Long answer: no


Right answer: it depends

See http://predef.sourceforge.net/

--
:: bartekd [at] o2 [dot] pl

Jul 22 '05 #3
bartek wrote:

Julie <ju***@nospam.c om> wrote in news:40******** *******@nospam. com:
Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


Short answer: no

Long answer: no


Right answer: it depends

See http://predef.sourceforge.net/

--
:: bartekd [at] o2 [dot] pl


On the contrary (and contrary to what is said in the link), those compiler
defines tell nothing of the actual operating system (or version), but at most,
tell the intended target operating system.

Right answer: no

If the OP wants a better answer, then they need to clarify as to specifically
what they are after as their post leaves a *lot* of room for
(mis)interpreta tion.
Jul 22 '05 #4
Julie <ju***@nospam.c om> wrote in news:40******** *******@nospam. com:
bartek wrote:

Julie <ju***@nospam.c om> wrote in news:40******** *******@nospam. com:
> Kevin A wrote:
>>
>> Hi,
>> Is there a way to determine the name and version of the
>> operating system in a portable way? (for Solaris/Linux)
>>
>> Thanks,
>>
>> Kevin
>
> Short answer: no
>
> Long answer: no


Right answer: it depends

See http://predef.sourceforge.net/

--
:: bartekd [at] o2 [dot] pl


On the contrary (and contrary to what is said in the link), those
compiler defines tell nothing of the actual operating system (or
version), but at most, tell the intended target operating system.

Right answer: no

If the OP wants a better answer, then they need to clarify as to
specifically what they are after as their post leaves a *lot* of room
for (mis)interpreta tion.


Therefore the good answer (from the OP's pov) is dependent on the OP's
particular requirements, i.e. what degree of portability is important for
the OP. The original message provides a clear indication that it's not
about absolute portability, in which case the strict answer 'no' is
misleading, at least. Of course, I'm not saying it isn't informative.

--
:: bartekd [at] o2 [dot] pl

Jul 22 '05 #5
Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


have you checked the man page for uname?
uname -a: returns all avaialble info for the given machine/OS.

Take a look at uname.
--
#----------------------------------------------------------#
# Penguinix Consulting #
#----------------------------------------------------------#
# Software development, QA and testing. #
# Linux support and training. #
# "Don't fear the penguin!" #
#----------------------------------------------------------#
# Registered Linux user: #309247 http://counter.li.org #
#----------------------------------------------------------#
Jul 22 '05 #6
Joe Cipale wrote:

Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


have you checked the man page for uname?
uname -a: returns all avaialble info for the given machine/OS.

Take a look at uname.


Not portable, nor standard C++.
Jul 22 '05 #7
> If the OP wants a better answer, then they need to clarify as to
specifically
what they are after as their post leaves a *lot* of room for
(mis)interpreta tion.
We are working on a project for school (university). We work on a server
that
runs Solaris, but some of us also work on our project at home using their
Linux.

For now I have solved this problem with a (ugly) temporary solution:

QString OS::getOperatin gSystem() {
return "Solaris 8";
}

But under Linux this, of course, gives the wrong result.

As you can see (from the use of QString), we use Qt. Maybe Qt has a way to
get
the name and version of the OS. But I can not find anything yet.
On the contrary (and contrary to what is said in the link), those compiler
defines tell nothing of the actual operating system (or version), but at most, tell the intended target operating system.


We compile on the same platform we run the program, so this IS a possible
solution. But if possible I would like a more elegant solution than using
macro's.
Kevin
Jul 22 '05 #8
Joe Cipale wrote:

Kevin A wrote:

Hi,
Is there a way to determine the name and version of the
operating system in a portable way? (for Solaris/Linux)

Thanks,

Kevin


have you checked the man page for uname?
uname -a: returns all avaialble info for the given machine/OS.

Take a look at uname.
--


Second that, but type

man 2 uname

Says it's POSIX.1. All reasonably modern Unices should be covered (SVr4
for sure), Linux too.

Certainly not C++, but while we are [OT] at it, it's about as portable
as it gets.

:-)

Denis
Jul 22 '05 #9
Kevin A wrote:
If the OP wants a better answer, then they need to clarify as to


specifically
what they are after as their post leaves a *lot* of room for
(mis)interpre tation.

We are working on a project for school (university). We work on a server
that
runs Solaris, but some of us also work on our project at home using their
Linux.

For now I have solved this problem with a (ugly) temporary solution:

QString OS::getOperatin gSystem() {
return "Solaris 8";
}

But under Linux this, of course, gives the wrong result.

As you can see (from the use of QString), we use Qt. Maybe Qt has a way to
get
the name and version of the OS. But I can not find anything yet.

On the contrary (and contrary to what is said in the link), those compiler
defines tell nothing of the actual operating system (or version), but at


most,
tell the intended target operating system.

We compile on the same platform we run the program, so this IS a possible
solution. But if possible I would like a more elegant solution than using
macro's.
Kevin


More elegant solution????

Commercial code like Qt uses a lot of macros for system dependent things.

They handle compatibility with autoconf automake, which generates the
appropriate macro definitions and makefiles for compiling in your system.

#ifdef linux
or #ifdef Linux

should just work, specially when all you have to comply is with Linux
and Solaris compatibility.

another thing you can try is using make rules.

Have your makefile include a golbal rules file

localrules.$(OS NAME)

eg

localrules.Linu x
localrules.Sola ris

You can use 'uname' to use the rules that apply to the system you are
compiling on, and maybe define compile time variables -DLIN_COMP_VAR.

Again, this is one of the things macros are good for. Don't be afraid
to use them....

Jorge L.
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4876
by: Nathan Sokalski | last post by:
I want to determine the operating system using ASP (or VBScript inside of ASP). I tried to get it using the Request. ServerVariables(EnvironmentVariable) method. On the web page about ASP in which I found this method, it gave a list of possible values for the EnvironmentVariable parameter. One of these, which is the one that I tried to use, was HTTP_UA_OS. However, this value did not seem to work, and when I displayed a list of possible...
3
5305
by: lucpustjens | last post by:
Hello, I want te determine the client operating system, because I need to kno the default cookie directory. If there is a way to determine the cooki directory directly, than it is also good. the used OS te determine are: win 95, win 98, win ME, win XP, win NT Thanks for help,
3
5913
by: Sisyphus | last post by:
Hi, Is there anything in the ANSI C standard covering the means by which I can determine the operating system and compiler being used (at the preprocess stage) ? If so, then how might I determine (at the preprocess stage) whether the operating system upon which the app is being built is Win32 or not, and whether the compiler being used is gcc or not ?
12
7824
by: Sunner Sun | last post by:
Hi, all Since the OS look both ASCII and binary file as a sequence of bytes, is there any way to determine the file type except to judge the extension? Thank you!
6
14323
by: Kaki | last post by:
Given a file, how do I know if it's ascii or unicode or binary? And how do I know if it's rtf or html or etc? In other words, how do I find the stream type or mime type? (No, file extension cannot be the answer) Thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
4472
by: Alex Vincent | last post by:
HI all, I'm storing images, jpgs/gifs/png/bmps and also some other binary files in a SQL image field in a SQL 2k database. Most of the images enter the database via a asp.net webform upload, here I can use HttpPostedFile.ContentType to enter into the db the contenttype of the file (because in some cases BMPs are actually renamed (by dumb users) to ..JPG which obviously causes problems...
7
23766
by: Ian F. Hood | last post by:
Hi In typically windows environments I have used: if 'Windows' in os.environ... to prove it, but now I need to properly support different environments. To do so I must accurately determine what system the python instance is running on (linux, win, mac, etc). Is there a best practises way to do this? TIA Ian
4
2238
by: Kenaso | last post by:
I know this has been asked before and I visited the VBNet website and ran the code to determine the operating system. My problem is I am running Windows Vista Home Edition. This code reports I am running Windows 2000. It reports the major=5, minor=0, and the build=2195. Has anyone ever seen such a thing? Has a specific file on my system been corrupted or overlaid by an earlier version? Any assistance would be appreciated. Thank you.
3
13234
by: Giampaolo Rodola' | last post by:
Hi, I'd like to know if there's a way to determine which is the best buffer size to use when you have to send() and recv() some data over the network. I have an FTP server application which, on data channel, uses 8192 bytes as buffer for both incoming and outgoing data. Some time ago I received a report from a guy who stated that changing the buffers from 8192 to 4096 results in a drastical speed improvement. I tried to make some tests...
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.