我实际上正在研究一个使用POST变量执行PowerShell脚本的PHP脚本。但是以某种方式,该脚本无法启动。
我已经用shell_exec尝试了很多东西: -切换引号 -更改脚本的路径 但什么都没有改变:/
long diff = DateTimeZone.getDefault().getOffset(yourTimeStapm) - TimeZone.getDefault().getOffset(yourTimeStapm);
执行该操作会生成PDF文件,但没有任何结果。 我的shell_exec是否正确? 感谢您的帮助!
答案 0 :(得分:0)
person
将 $command = shell_exec('powershell ./Script.ps1 -FirstName "'.$FristName.'" -LastName "'.$LastName.'" -Description "'.$desc.'" -Type "'.$type.'" -AGOL $true ');
附加到powershell
函数的开头应该会产生所需的结果。
答案 1 :(得分:0)
您的一个变量名中有一个错字,可能引起问题。
<?php
//Shell_Exec ('powershell.exe -executionpolicy bypass -NoProfile -Command "Get-Process | ConvertTo-Html"');
//storaging the variables passed by POST
$LastName = $_POST["LastName"];
$FirstName = $_POST["FirstName"];
$type = $_POST["type"];
$begin = $_POST["begin"];
$end = $_POST["end"];
$desc = $_POST["desc"];
/*
* Use $FirstName, not $FristName
*/
$command = shell_exec('./Script.ps1 -FirstName "'.$FirstName.'" -LastName "'.$LastName.'" -Description "'.$desc.'" -Type "'.$type.'" -AGOL $true ');
?>
答案 2 :(得分:0)
出口处显示什么?
<?php
$output = shell_exec('Script.ps1 -FirstName "'.$FristName.'" -LastName "'.$LastName.'" -Description "'.$desc.'" -Type "'.$type.'" -AGOL $true');
echo "<pre>$output</pre>";
?>