I have a webpage with a HTML button. The webpage is located in /var/www/html and is named index.php. In the same folder I have a file called "running.php". The contents of running.php is below:
#!/usr/bin/php
<?php
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'test' : test();
break;
}
}
function test(){
exec("/usr/sapint/outgoing/ihprocess",$output);
print_r($output);
}
?>
when I run the file from command line on the server as ./running.php the file executes perfectly. I want to be able to execute this file from the HTML webpage.
I have played around with all the options such as exec, permissions etc but nothing seems to work.
I currently have in my index.php file
<a id="run" class="btn btn-primary" onclick="ajaxcall()">Process Files </a>
function ajaxcall() {
$.ajax({ url: 'running.php',
data: {action: 'test'},
type: 'post',
success: function(output) {
alert(output);
}
});
}
any help would be appreciated.