我有一个网站,我在 JS 中创建了一个简单的表单: Launch form
function()
{
var thePrompt = window.open("", "", "widht=50");
var theHTML = "";
theHTML += "<p>Please insert the IP,TestCaseID and your credentials</p>";
theHTML += "<br/>";
theHTML += "IPprinter: <input type='text' id='theIP' placeholder='Enter Printer IP'/>";
theHTML += "<br/>";
theHTML += "TestCaseID: <input type='text' id='theID' placeholder='Enter TestCase ID'/>";
theHTML += "<br/>";
theHTML += "Username: <input type='text' id='theUser' placeholder='Enter Username'/>";
theHTML += "<br />";
theHTML += "Password: <input type='text' id='thePass' placeholder='Enter Password'/>";
theHTML += "<br />";
theHTML += "<input type='button' value='Launch' id='Launch'/>";
thePrompt.document.body.innerHTML = theHTML;
var theIP = thePrompt.document.getElementById("theIP").value;
var theID = thePrompt.document.getElementById("theID").value;
var theUser = thePrompt.document.getElementById("theUser").value;
var thePass = thePrompt.document.getElementById("thePass").value;
thePrompt.document.getElementById("Launch").onclick = function () {
var process = require('child_process');
process.exec('./var/www/html/mytest/TestAPI.sh',function (err,stdout,stderr) {
if (err) {
console.log("\n"+stderr);
} else {
console.log(stdout);
}
});
}
当我单击“启动”按钮从“/var/www/html/mytest/TestAPI.sh”启动脚本时,没有任何反应。我哪里错了,或者有其他方法可以执行该脚本,也许使用 PHP?!
我知道这似乎是从网页启动脚本的安全漏洞,但这是在用户登录后在受控环境中完成的。欢迎任何想法...
不负相思意
慕虎7371278