Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Idenifying the OS the perl script is runnning on

by narashima (Beadle)
on Jul 11, 2007 at 21:02 UTC ( [id://626084]=perlquestion: print w/replies, xml ) Need Help??

narashima has asked for the wisdom of the Perl Monks concerning the following question:

Revered Monks,

Could you please tell me how I can identify if my perl script is running on Windows or Unix(Solaris)?

I want to make the script different way depending on the OS it is running on.

Thanks!
  • Comment on Idenifying the OS the perl script is runnning on

Replies are listed 'Best First'.
Re: Idenifying the OS the perl script is runnning on
by FunkyMonk (Chancellor) on Jul 11, 2007 at 21:11 UTC
    $^O (letter O, not zero) will tell you which OS perl was built under, which in your case, should be good enough (it isn't very good at distinguishing between Windows variants).

    You can read all about it in perlvar.

      If the program needs to know the flavour of Windows, it can call Win32's GetOSVersion after ascertaining it's running on a Win32 machine.
Re: Idenifying the OS the perl script is runnning on
by regexes (Hermit) on Jul 12, 2007 at 07:02 UTC
    Hello,

    To extrapolate on what FunkyMonk said..
    I had somewhat of the same question answered by Fletch here.. Re: OS400 Pace - architecture?

    The $^O variable only contains the architecture the platform was built on. If you want to know on which platform it's running try using uname with backticks on a Unix platform and/or ver on a Windows box.

    regexes


    -------------------------
    Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan "press on" has solved and always will solve the problems of the human race.
    -- Calvin Coolidge, 30th President of the USA.
      On Linux, the pseudo file /proc/version may provide flavor information. Cheers.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://626084]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found