Jump to content

Recommended Posts

G'day All,

I am trying to understand how to define specific environmental variables needed to run a system command from php? I am using the system() to call the command but even though the user account has the environmental variable set, it does not appear to be used when issuing the command from within my php code.

Not sure what I am missing and all the searches I have done with regard to defining environmental variables within php code seem vague if not non-existant.

Any help would be appreciated and thanks in advance...

DannyG
Link to comment
https://forums.phpfreaks.com/topic/11909-environmental-variables/
Share on other sites

OK,

I figured it out. You can use the putenv() function to add environmental variables if you are not running php in safe mode. It allows you to do something as follows:

[code]
putenv('HOME=/opt/app/p1momw1');
[/code]

This allows the php script to use this environmental each time the script is called. I would assume you could also use an include file if it was needed in multiple pages...

Anyway, I am glad...

DannyG
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.