I have another script, but I simplified it to simulate the problem that persists.
test.sh
#!/bin/bash
ARRAY=('like' 'a' 'stone')
echo ${ARRAY[0]}
In the file below, I have already made sure that shell_exec
is actually executing the above command.
index.php
<?php
$comando = file_get_contents("teste.sh");
echo "<pre>";
var_dump(shell_exec($comando));
echo "</pre>";
Here I am expecting you to print like
, but the result always comes null as below.
Output
NULL
However, if I change my teste.sh
to only php -v
, it prints the version of my PHP. Which is not what I want, but it serves as a stupid strip.
Output
string(235) "PHP 5.5.9-1ubuntu4.17 (cli) (built: May 19 2016 19:05:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
"
Then I get confused, like he is not able to print what I'm hoping for? What am I doing wrong?