No return with shell_exec in PHP

Asked

Viewed 98 times

0

Recently the need arose to take advantage of some functions of a program with pascal language compiled with "fpc" in PHP, the same runs perfectly by the terminal in Debian, the program is very simple and is of console type, the call is made as follows by passing as parameter any text, eg: ./encrypt "HELLO" and the result is a simple text line generated by the command writeln(func_encrypt('C',ParamStr(1)));, soon after the program is finished. Of the ways I have tried, no return is displayed by PHP, neither result nor errors. I tried using the following functions:

$output = shell_exec('encrypt "HELLO"');
echo $output; //nenhum resultado

$output = exec('encrypt "HELLO"');
echo $output; //nenhum resultado

$output = system('encrypt "HELLO"');
echo $output; //nenhum resultado

I also tried to inform in the parameter './encrypt "HELLO"' and '/caminho_completo/encrypt "HELLO"' and by surprise also nothing happens.

Using any of the above functions, the command date shows the output perfectly.

Does the error lie in how the output of the text is displayed in the program?

  • The php are you allowed to run the pascal code? If not, just use the command sudo chmod +x /path/to/encrypt. You can also use redirects, for example: /path/to/encrypt 2>&1

  • I believe it is not problem with permission, previously I had already assigned: chmod 777 encrypt...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.