determine operating system

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin A

    #16
    Re: determine operating system

    > have you checked the man page for uname?[color=blue]
    > uname -a: returns all avaialble info for the given machine/OS.[/color]

    I just looked at the manpages for uname and I tried "uname -sr".
    However, I was a little surprised by the result, since it printed
    "SunOS 5.8" and the comments that appear when I log in remotely
    to the server say that it runs Solaris 8. (If those two are the same,
    please tell me)

    And another thing: how can I call this from our C++ code?
    I suppose using the system() function. But then, how can I get the
    result that this function prints?


    Kevin


    "Joe Cipale" <joec@aracnet.c om> schreef in bericht
    news:40A02504.B A30458F@aracnet .com...[color=blue]
    > Kevin A wrote:[color=green]
    > >
    > > Hi,
    > > Is there a way to determine the name and version of the
    > > operating system in a portable way? (for Solaris/Linux)
    > >
    > > Thanks,
    > >
    > > Kevin[/color]
    >
    > 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 #
    > #----------------------------------------------------------#[/color]


    Comment

    • Julie

      #17
      Re: determine operating system

      Kevin A wrote:[color=blue]
      >[color=green]
      > > have you checked the man page for uname?
      > > uname -a: returns all avaialble info for the given machine/OS.[/color]
      >
      > I just looked at the manpages for uname and I tried "uname -sr".
      > However, I was a little surprised by the result, since it printed
      > "SunOS 5.8" and the comments that appear when I log in remotely
      > to the server say that it runs Solaris 8. (If those two are the same,
      > please tell me)
      >
      > And another thing: how can I call this from our C++ code?
      > I suppose using the system() function. But then, how can I get the
      > result that this function prints?[/color]

      None of this is on topic, relevant, or able to be answered within this forum.

      Your best bet is to take your question to a Solaris/Unix/Linux forum and post
      it there.

      Comment

      • Marc

        #18
        Re: determine operating system

        "Kevin A" wrote :
        [color=blue]
        > I just looked at the manpages for uname and I tried "uname -sr".
        > However, I was a little surprised by the result, since it printed
        > "SunOS 5.8" and the comments that appear when I log in remotely
        > to the server say that it runs Solaris 8. (If those two are the same,
        > please tell me)[/color]

        Indeed they are. Well actually one is only the operating system and the
        other one includes the remaining tools, but basically it is the same.
        [color=blue]
        > And another thing: how can I call this from our C++ code?
        > I suppose using the system() function. But then, how can I get the
        > result that this function prints?[/color]

        try "man 2 uname" instead of "man uname".

        Comment

        • Jorge Rivera

          #19
          Re: determine operating system

          Kevin A wrote:
          [color=blue][color=green]
          >>#ifdef linux
          >> or #ifdef Linux
          >>
          >>should just work, specially when all you have to comply is with Linux
          >>and Solaris compatibility.[/color]
          >
          >
          > I just found a reason why this is not the solution I'm looking for.
          > I'd like to have the entire name of the OS, something like
          > "Suse Linux" and its version number.
          > But the macro's can only answer: "is it Linux, yes or no?"
          >
          >
          > Kevin
          >[/color]
          You can get uname to give you more insight. I dont't rember what
          exactly, but uname will indeed give you more information than just Linux
          or Solaris, although I don't know if Suse will be in the information.

          From there on, you will then need to define your own macros given the
          information requested.

          I do really think that all your problems can be solved through the use
          of autoconf automake, but you'll have to do your own research on this...

          Jorge L.

          Comment

          • Jorge Rivera

            #20
            Re: determine operating system

            > Not in the std C++ sense.

            I guess that the point here is how to do this. You are correct, and so
            are they. Among any Unix variant, uname is great, and hence it is
            protable...

            JLR

            Comment

            • Thomas Matthews

              #21
              Re: determine operating system

              Joe Cipale wrote:
              [color=blue]
              > Julie wrote:
              >[color=green]
              >>Joe Cipale wrote:
              >>[color=darkred]
              >>>Julie wrote:
              >>>
              >>>>Joe Cipale wrote:
              >>>>
              >>>>>Kevin A wrote:
              >>>>>
              >>>>>>Hi,
              >>>>>>Is there a way to determine the name and version of the
              >>>>>>operati ng 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++.
              >>>
              >>>Funny...
              >>>
              >>>works the same on my BSD/Solaris/Linux machines (just a small sample)...
              >>>~sheesh~[/color]
              >>
              >>So is your point that it is standard C++ and/or portable?[/color]
              >
              >
              > it is portable...[/color]

              I tried this on VRTX operating system. No such command.
              I tried this on MSDOS operating system. No such command.
              I tried this on VAX operating system. No such command.
              I tried this on our custom OS for an embedded system. No such command.

              How could it be portable?


              --
              Thomas Matthews

              C++ newsgroup welcome message:

              C++ Faq: http://www.parashift.com/c++-faq-lite
              C Faq: http://www.eskimo.com/~scs/c-faq/top.html
              alt.comp.lang.l earn.c-c++ faq:

              Other sites:
              http://www.josuttis.com -- C++ STL Library book

              Comment

              • Thomas Matthews

                #22
                Re: determine operating system

                Jorge Rivera wrote:
                [color=blue][color=green]
                >> Not in the std C++ sense.[/color]
                >
                >
                > I guess that the point here is how to do this. You are correct, and so
                > are they. Among any Unix variant, uname is great, and hence it is
                > protable...
                >
                > JLR[/color]

                But it is only protable [sic] to *Nix operating systems.
                There are plenty of operating systems out there that
                are neither MS Windows or *NIX.

                For example, the MS-DOS operating system doesn't have uname.
                Neither does: VAX, VRTX, nor custom operating systems.
                Don't assume that the entire world has your operating system.
                Many embedded systems either have no operating system,
                proprietary OS or off-the-shelf OS. Many of which don't
                support file systems or the uname command.


                --
                Thomas Matthews

                C++ newsgroup welcome message:

                C++ Faq: http://www.parashift.com/c++-faq-lite
                C Faq: http://www.eskimo.com/~scs/c-faq/top.html
                alt.comp.lang.l earn.c-c++ faq:

                Other sites:
                http://www.josuttis.com -- C++ STL Library book

                Comment

                • Buster

                  #23
                  Re: determine operating system

                  Thomas Matthews wrote:
                  [color=blue]
                  > How could it be portable?[/color]

                  It is portable, within a certain domain. You can 'carry' it from one
                  UNIX-like system to another. The word is being used in a sensible way.
                  Standard C++ is not "portable" if that means it has to work for every
                  computer ever built.

                  --
                  Regards,
                  Buster.

                  Comment

                  • Karl Heinz Buchegger

                    #24
                    Re: determine operating system

                    Buster wrote:[color=blue]
                    >
                    > Thomas Matthews wrote:
                    >[color=green]
                    > > How could it be portable?[/color]
                    >
                    > It is portable, within a certain domain.[/color]

                    Then it is of no interrest to comp.lang.c++
                    Plain and simple.
                    [color=blue]
                    > You can 'carry' it from one
                    > UNIX-like system to another. The word is being used in a sensible way.
                    > Standard C++ is not "portable" if that means it has to work for every
                    > computer ever built.[/color]

                    Exactly that is the intent of Standard C++.
                    IF there is a C++ compiler on that machine AND
                    that compiler is standard compliant AND
                    the program uses only standard C++ constructs AND
                    the program doesn't contain undefined behaviour

                    THEN
                    the compiler can compile that program and
                    a program run will produce identical output

                    Granted: There is only 1 compiler currently known which is fully
                    standard compliant. But all the others are close to it and the
                    non standard compliant areas in them mostly deal with 'esoteric'
                    corners of the language which are not used by many programmers.

                    --
                    Karl Heinz Buchegger
                    kbuchegg@gascad .at

                    Comment

                    • Kevin A

                      #25
                      Re: determine operating system

                      > Short answer: no[color=blue]
                      >
                      > Long answer: no[/color]

                      Then C++ is too limited :)


                      Kevin


                      Comment

                      • Joe Cipale

                        #26
                        Re: determine operating system

                        Karl Heinz Buchegger wrote:[color=blue]
                        >
                        > Buster wrote:[color=green]
                        > >
                        > > Thomas Matthews wrote:
                        > >[color=darkred]
                        > > > How could it be portable?[/color]
                        > >
                        > > It is portable, within a certain domain.[/color]
                        >
                        > Then it is of no interrest to comp.lang.c++
                        > Plain and simple.
                        >[color=green]
                        > > You can 'carry' it from one
                        > > UNIX-like system to another. The word is being used in a sensible way.
                        > > Standard C++ is not "portable" if that means it has to work for every
                        > > computer ever built.[/color]
                        >
                        > Exactly that is the intent of Standard C++.
                        > IF there is a C++ compiler on that machine AND
                        > that compiler is standard compliant AND
                        > the program uses only standard C++ constructs AND
                        > the program doesn't contain undefined behaviour
                        >
                        > THEN
                        > the compiler can compile that program and
                        > a program run will produce identical output
                        >
                        > Granted: There is only 1 compiler currently known which is fully
                        > standard compliant. But all the others are close to it and the
                        > non standard compliant areas in them mostly deal with 'esoteric'
                        > corners of the language which are not used by many programmers.
                        >
                        > --[/color]

                        Agreed Karl...
                        --
                        #----------------------------------------------------------#
                        # Penguinix Consulting #
                        #----------------------------------------------------------#
                        # Software development, QA and testing. #
                        # Linux support and training. #
                        # "Don't fear the penguin!" #
                        #----------------------------------------------------------#
                        # Registered Linux user: #309247 http://counter.li.org #
                        #----------------------------------------------------------#

                        Comment

                        • Joe Cipale

                          #27
                          Re: determine operating system

                          Thomas Matthews wrote:[color=blue]
                          >
                          > But it is only protable [sic] to *Nix operating systems.
                          > There are plenty of operating systems out there that
                          > are neither MS Windows or *NIX.
                          >[/color]

                          The person who posted the original question posted it regarding *nix
                          operating systems.

                          Joe
                          --
                          #----------------------------------------------------------#
                          # "Don't fear the penguin!" #
                          #----------------------------------------------------------#
                          # Registered Linux user: #309247 http://counter.li.org #
                          #----------------------------------------------------------#

                          Comment

                          • Default User

                            #28
                            Re: determine operating system

                            Karl Heinz Buchegger wrote:
                            [color=blue]
                            > Exactly that is the intent of Standard C++.
                            > IF there is a C++ compiler on that machine AND
                            > that compiler is standard compliant AND
                            > the program uses only standard C++ constructs AND
                            > the program doesn't contain undefined behaviour[/color]

                            the program doesn't contain implementation-defined behavior
                            the program doesn't contain unspecified behavior
                            the program doesn't contain locale-specific behavior


                            I-D is a special case of unspecified behavior, of course.

                            [color=blue]
                            > THEN
                            > the compiler can compile that program and
                            > a program run will produce identical output[/color]



                            Brian Rodenborn

                            Comment

                            Working...