Set Path in *nix

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Little

    #1

    Set Path in *nix

    I need to be able to set the command path from PHP on any *nix system, any
    shell. I know there are different formats depending on the shell; when I do
    a getenv(), it shows the colon-delimited format, but when I try to change
    it with putenv(), it's ignored, no matter what format I use, or even if I
    give it just a single path.

    --
    Alan Little
    Phorm PHP Form Processor

  • Brion Vibber

    #2
    Re: Set Path in *nix

    Alan Little wrote:[color=blue]
    > I need to be able to set the command path from PHP on any *nix system, any
    > shell. I know there are different formats depending on the shell; when I do
    > a getenv(), it shows the colon-delimited format, but when I try to change
    > it with putenv(), it's ignored, no matter what format I use, or even if I
    > give it just a single path.[/color]

    Can you give a code sample of exactly what you're doing? Normally
    something like this should work:

    putenv('PATH=/bin:/usr/bin:/foobar');
    # ... run commands requiring PATH change

    As far as I know, this shouldn't be shell-dependent.

    (Remember that changes to the environment will only be in effect for the
    process you change it in and any child processes you spawn afterwards.
    So for instance running a PHP script from a shell will not change the
    environment in the shell that you ran it from.)

    -- brion vibber (brion @ pobox.com)

    Comment

    Working...