Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

setenv

by Pearte (Beadle)
on Jul 25, 2000 at 00:54 UTC ( [id://24184]=perlquestion: print w/replies, xml ) Need Help??

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

Well I have a chunk of code that I didn't write: (endline) setenv RAP_WP_TOP_DIR /jdev/morse/shared (endline) setenv WP_DEFAULT_CONFIG_DIR /jdev/morse/shared/config/wp_default (endline) setenv WP_LC_CONFIG_DIR /jdev/morse/shared/config/jnu_lc (endline) setenv WP_ND_CONFIG_DIR /jdev/morse/shared/config/jnu_nd (endline) setenv WP_SD_CONFIG_DIR /jdev/morse/shared/config/jnu_sd (endline) (endline) I can only assume from the context that this is similar to a filehandle and that these "filehandles" can be passed between diffent scripts. I have three questions: One... Is this assumption correct? Two... If so, what kind of rules regulate it's use? In other words, what do I have to do to let these other scripts see it? Three.. If my assumption is incorrect, what is this all about? Thanks, Pearte PS- I checked two O'Reilly's, no dice. PPS- I would love to know who to format text in this silly box.

Replies are listed 'Best First'.
RE: setenv
by steveAZ98 (Monk) on Jul 25, 2000 at 01:06 UTC
    setenv sets enviorment variables in a unix system. I would assume it is in a file with a leading #!/bin/sh at the top. All it does is set these enviorment variables to the corrosponding filenames when it is run by the shell.

    Your assumption is correct in that you can now access these vars from a perl script using %ENV
    ie. $ENV{WP_DEFAULT_CONFIG_DIR}

    On other systems you may have to set the enviorment vars with: export VAR=value

    To format code use
    <code> and </code>
    The rest can be formatted with standard HTML.
    HTH
      well technically setenv is a csh'ism, so you would expect to see #!/bin/csh at the top.

      the equivalent /bin/sh'ism would be

      VAR="this is the value of the variable" export VAR

      </offtopic nitpicking>
      -Mark

        Now that we're nitpicking....
        export VAR="foo? bar! baz..."

        update: this is actually a bash thingy (or ksh. thanks tye!)

        -- ar0n

Re: setenv
by fundflow (Chaplain) on Jul 25, 2000 at 01:39 UTC
    The enviromnent variables are part of the environment supplied by the operating system, just like memory and disk access.
    (This is true for Unixes, i don't know about DOS)

    Any program has a mechanism can set these variables in its memory space. These values get transfered to new children via the fork() system call. This is the reason that you can set such variable in bash/csh/tcsh etc and then run a program (i.e. fork) which can see these variables.

    If memory serves, the C library has the info about it.
    The perl way is $ENV{WHATEVER} as was mentioned above.

    Cheers :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2025-03-27 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (70 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.