Exec () does not work in PHP

I have a PHP script in which I need to execute a shell script 'add_article.sh' that reads the parameters file and adds the contents of the news article to the search index (Lemur / Indri).

Running the 'add_article.sh' script myself (from the shell) works fine, but runs it from a php script, I get the following:

$blah = exec("./add_article.sh", $out, $ret_val);

echo $out . "<BR />";
echo $ret_val . "<BR />";

It creates

<i> Array>
<i> 255

It is in the correct directory and does not work even with an absolute path. I use the exact same format in another function in the same file that executes another script in the same directory, and everything is fine.

Any ideas?

+3
source share
3 answers

script? Apache , .

+1

$out . , print_r() var_dump() , script; , .

, , - , , PHP script. , Apache.

+1

Try:

$blah = exec("./add_article.sh", $out, $ret_val);

print_r($out);
echo '<br />';
echo $ret_val . "<br />";
+1
source

Source: https://habr.com/ru/post/1713943/


All Articles