我试图在下面运行这个
javascript但是没有看到php shell_exec命令的输出.
运行测试-a bash脚本将输出一系列ID为34535,25643,23262等.当我在我的PHP文件中运行它与一个简单的工作正常.
print shell_exec('/opt/bin/echkchunk -a');
但是当我尝试在下面运行它并选择test1时,没有任何内容输出到屏幕上.通过chromes开发人员工具,我可以看到选择test1时的代码如下
< ;! – ?php shell_exec(“/ opt / bin / echkchunk -a”); ? – >
好像它被注释掉了.
所以我的问题是,是否可以使用php和JavaScript以这种方式运行bash脚本?或者有没有其他方法可以在没有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");
}
});
});