FMashiro gives you the right answer.
According to this answer here is an example.
Firstly you have to ensure to have the correct permissions.
Be sure your user/group has the same as your web files. If not change it via:
chown
Your html looks like this:
<div class="example">
<button type="button" name="button" onclick="myscriptcaller()">Click</button>
</div>
<script type="text/javascript">
function myscriptcaller() {
$.$.ajax({
url: '/path/to/yourphpfile.php',
type: 'GET',
dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
data: {param1: 'value1'}
})
.done(function() {
console.log("success");
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
}
</script>
Please don't put your files in home/username, your scripts might be located in a folder which is reachable from www but not from the public area.
Discussed and described in Executing a Bash script from a PHP script
After that, you should have a folder reachable as described in the post.
e.g. /var/www/yourdesireddestination
And your php file:
<?php
$message=shell_exec("/var/www/yourdesireddestination/auto.sh");
print_r($message);
?>