php - get value of variables defined in shell script -
how can value of variable defined in shell script? (the script configuration file, contains variable-definitions) cannot use "source" command in exec:
echo exec('var=2; echo $var'); //writes "2" echo exec('source config.sh; echo $var'); //writes ""
how can value of variables defined in shell script?
userthis worked me on terminal:
echo var=2 > shellscript echo "<?php echo exec('source /home/user/shellscript; echo $var'); ?>" > phpscript.php ls | grep script phpscript.php shellscript php phpscript.php 2
so wrote shellscript, php read shell script , ran php script. did wanted.
maybe can add other exec components clue?
<?php echo exec('source /home/user/shellscript; echo $var',$out,$ret); echo "\nout0: ". $out[0]. "\nret: $ret\n"; ?>
this shows me:
~]$ php phpscript.php 2 out0: 2 ret: 0
Comments
Post a Comment