触发js运行php,使用php exec和javascript执行bash脚本

我试图在下面运行这个

javascript但是没有看到php shell_exec命令的输出.

运行测试-a bash脚本将输出一系列ID为34535,25643,23262等.当我在我的PHP文件中运行它与一个简单的工作正常.

print shell_exec('/opt/bin/echkchunk -a');

但是当我尝试在下面运行它并选择test1时,没有任何内容输出到屏幕上.通过chromes开发人员工具,我可以看到选择test1时的代码如下

&lt ;! – ?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");

}

});

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值