Kriti Singh
Kriti Singh

Reputation: 19

Execute a compiled file using PHP

I have an executable which i wish to execute using PHP. I am using centOS as my server. I created a PHP file execute.php with following code in it:

<?php
    echo shell_exec("/var/www/html/myfolder/a.out");
?>

I have also give executing permission to user apache

Still php is not able to execute my file when i browse to execute.php

EDIT: I am able to execute the file using terminal -> php execute.php

EDIT-2: A little progress. It's giving me permission issue error now.

Any help would be appreciated

Upvotes: 1

Views: 63

Answers (2)

Scott C Wilson
Scott C Wilson

Reputation: 20016

<?php
    system("./a.out");
?>

Upvotes: 2

Amit Prajapati
Amit Prajapati

Reputation: 41

write like this-

$value = shell_exec('/var/www/html/myfolder/a.out'); echo $value;

and also note this function is disabled when php runs in safe mode.

Upvotes: 0

Related Questions