johnsiilver Posted October 20, 2006 Share Posted October 20, 2006 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 https://forums.phpfreaks.com/topic/24508-how-to-access-environmental-variables-from-commandline-php/ Share on other sites More sharing options...
printf Posted October 20, 2006 Share Posted October 20, 2006 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 https://forums.phpfreaks.com/topic/24508-how-to-access-environmental-variables-from-commandline-php/#findComment-111645 Share on other sites More sharing options...
trq Posted October 20, 2006 Share Posted October 20, 2006 [quote]I've been trying to set an $_env[], $_session[], or a $global[] variable and have it read by the commandline script, but no luck.[/quote]Maybe because they are $_ENV[], $_SESSION[] and $GLOBALS[] respectfully. Link to comment https://forums.phpfreaks.com/topic/24508-how-to-access-environmental-variables-from-commandline-php/#findComment-111646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.