2
I have another script, but I simplified it for this to simulate the problem that persists.
test sh.
#!/bin/bash
ARRAY=('like' 'a' 'stone')
echo ${ARRAY[0]}
In the file below, in another moment I already made sure that the shell_exec
is actually running the above command.
index php.
<?php
$comando = file_get_contents("teste.sh");
echo "<pre>";
var_dump(shell_exec($comando));
echo "</pre>";
Here I’m waiting for you to print like
, but the result always comes null as below.
Exit
NULL
But if I change mine teste.sh
to just php -v
, it prints the version of my PHP. What is not what I want, but serves as strip web.
Exit
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 cranky, like he’s not able to print what I’m waiting for ? What am I doing wrong ?
Opá, Deu certinho. You saved my life. Thank you @zekk. I chose to use more the first way.
– William Novak