【发布时间】:2018-10-27 07:11:25
【问题描述】:
我正在运行以下 php 脚本。它创建了一个运行几个 docker 命令的脚本文件。但是这个脚本文件由于某种原因没有运行 docker 命令。它运行正常的脚本文件命令,如 ls、pwd、echoetc。
$code = $_POST['source'];
$myfile = fopen("abc.py", "w");
fwrite($myfile, $code);
$myfile_new = fopen("execu_ta.sh", "w");
$txt = "#!/bin/bash\n\n";
fwrite($myfile_new, $txt);
$txt1 = "docker build -t python-new-world .";
$txt2 = "docker run python-new-world\n";
fwrite($myfile_new, $txt1);
fwrite($myfile_new, $txt2);
$result=shell_exec('path of the "execu_ta.sh" file');
echo $result;
?>
这里可能有什么问题?
【问题讨论】:
-
需要设置可执行位或者使用
shell_exec('/bin/bash your_script') -
@Ujin,也许您可以添加您的评论作为答案,这样您就可以获得荣誉?