Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

finiding the os type

by DS (Acolyte)
on Aug 05, 2002 at 13:45 UTC ( [id://187661]=perlquestion: print w/replies, xml ) Need Help??

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

Hello guys , I am trying to check my OS type here :
if (( $OSTYPE eq "cygwin" ) or ( $TERM eq "cygwin" )) { $DRIVENAME=`pwd | tr '/' ' ' | gawk '{print $1}'`; # additional check for newer versions of cygwin that # do not support //drivename conventions if ( $DRIVENAME eq "cygdrive" ) { $DRIVENAME=`pwd | tr '/' ' ' | gawk '{print $2}'`; $BASEDIR="/cygdrive/$DRIVENAME"; } else { $BASEDIR="//$DRIVENAME"; } $NICE=`nice -n +10`; } else { $BASEDIR="/vobs/nbss"; $NICE=""; }
but it don't seem to do the job , do you see the problem , thanks

Replies are listed 'Best First'.
Re: finiding the os type
by davorg (Chancellor) on Aug 05, 2002 at 14:00 UTC

    You should probably show us the code that sets those variables.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: finiding the os type
by RollyGuy (Chaplain) on Aug 05, 2002 at 14:36 UTC
    It looks like you are trying to use your environment variables (OSTYPE, TERM) directly. In order to get to the environment variables that you want, you need to use the %ENV hash. This hash contains all of your environment variables. Just supply the environment variable name as the key to the hash to get the value.

    So, your first line would look like:

    if (( $ENV{OSTYPE} eq "cygwin" ) or ( $ENV{TERM} eq "cygwin" )) Enjoy.
      thanks much ,, that help a lot :)
Re: finiding the os type
by TStanley (Canon) on Aug 05, 2002 at 14:27 UTC
    The internal variable for the OS type is $^O

    TStanley
    --------
    Never underestimate the power of very stupid people in large groups -- Anonymous
Re: finiding the os type
by ichimunki (Priest) on Aug 05, 2002 at 17:33 UTC
    but it don't seem to do the job , do you see the problem

    And after all that code you were so close! The problem is that your code probably runs just fine, but doesn't do what you thought it ought to. You don't appear to be using strict, otherwise I'd guess the above snippet wouldn't even compile. Or, as another possibility, you set all your $VARIABLES somewhere else in the script, but don't show us where. And finally, you tell us what you're trying to do, but you don't tell us what post-conditions you are finding that are unsatisfactory, or what error messages your script is generating. Unless you give us this information, we're forced to guess at what you meant to ask, what other code this script might contain, and what you really mean when you say "it don't seem to do the job".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found