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!
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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.