TeaNyan
TeaNyan

Reputation: 5079

Open executable with php

How to open executable (GNU/Linux) with php?

exec and system are not working for me.

Since I have tried multiple different options, I'm here to ask you. I never had any experience with php (I work with C), so I'm stuck at probably something simple, yet so hard for me. I have tried this:

<?php

string exec('add_user email password');

?>

and many other possibilities. add_user is an executable written in C++. It is located in root folder, in html folder and apache2 folder (just in case), so it's not the path at fault. Email and password are parameters. I have tried both exec() and system(), nothing happens. I have even tried 'whoami', nothing. When I says nothing happens, I really mean it. I call the php with browser "localhost/test.php", just get blank site. If I try echo 'string'; i still get nothing.

Upvotes: 2

Views: 60

Answers (1)

Leo Chapiro
Leo Chapiro

Reputation: 13979

Try shell_exec:

<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>

Upvotes: 1

Related Questions