just do it with php, then call the shell script to call the php script.
Assuming you have a bunch of definitions defined in defs.php
:
define('NAME', 'JOHN'); define('HOBBY', 'FISHING');
then create php script get_defs.php
:
require_once 'defs.php'; $const = get_defined_constants(true); foreach($const['user'] as $k => $v) { echo "export $k=$v"; }
then in your shell script run it like this:
`php get_defs.php`
What happens, get_defs.php will output a bunch of export KEY=VALUE
, then the shell will run the commands that you entered in your php get_defs.php
.
source share