Jump to content

How to access environmental variables from commandline php


johnsiilver

Recommended Posts

I was hoping someone might be able to point me in the right direction.

I have a webbased php script that exec()'s some php commandline scripts.  These scripts log onto various machines and do work, and I would like to avoid passing the password on the commandline, which could be seen by someone doing a 'ps -ef'.  I've been trying to set an $_env[], $_session[], or a $global[] variable and have it read by the commandline script, but no luck.

Anyone know how to do this?  Thanks!
Link to comment
Share on other sites

In Apache you can use, the [b]SetEnv[/b] directive, other servers also support it, but in different ways. You can also set it via htaccess, so as to restrict who can access that environment variable! You can't set a $_ENV['var'] in PHP and expect it to be available from other scripts, it doesn't work that way. PHP can only write to the $_ENV array in it's local context, only the server has global scope! Unless you use the prepend file option within PHP, via htaccess, per directory option!

me!
Link to comment
Share on other sites

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.