I am trying to run this javascript below but cannot see the php shell_exec command output.
Running the test -a bash script will print a series of ID 34535, 25643, 23262, etc. When I run it in my php file with a simple one, it works fine.
print shell_exec('/opt/bin/echkchunk -a');
But when I try to run it below, and I select test1, nothing is displayed. Looking through the chromes developer tools, I see the code when test1 is selected as
<!--?php shell_exec("/opt/bin/echkchunk -a"); ?-->
as if he was commenting out.
So my question is: is it possible to run a bash script using php and JavaScript? Or is there another way to get this information displayed on a web page without JavaScript?
<script type="text/javascript"> var tester = '<?php shell_exec("/opt/bin/test -a"); ?>'; $(document).ready(function() { $("#selector").on("change", function() { if ($("#selector").val() == "test1") { $("#rightselection").css("background-color", "red"); $("#rightselection").html(tester); } if ($("#selector").val() == "test2") { $("#rightselection").css("background-color", "blue"); $("#rightselection").html("test2"); } if ($("#selector").val() == "test3"){ $("#rightselection").css("background-color", "yellow"); $("#rightselection").html("test3"); } if ($("#selector").val() == ""){ $("#rightselection").css("background-color", "green"); $("#rightselection").html("This is a Test"); } }); }); </script>
source share