I am trying to set a bash environment variable using PHP (from the command line) without success.
$buff=array(); $buff[]="VARTESTKEY=VARTESTVALUE"; $buff[]="export VARTESTKEY"; file_put_contents('script.sh', implode("\n",$buff)); system('source script.sh');
I even tried using a script to output a key value that gets the value:
$buff=array(); $buff[]="echo VARTESTKEY=VARTESTVALUE"; file_put_contents('script.sh', implode("\n",$buff)); system('eval "$(bash script.sh)"');
But still nothing.
Any ideas? I do not mind using any other tool (perl, python, c, etc.) if it can do its job by calling from a PHP system function.
source share