且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用 PHP 运行 shell 脚本文件

更新时间:2023-01-23 10:24:54

试试这个:

您需要做的是用程序调用该文件.按照评论中的建议使用 bash 或 sh 调用它:

What you need to do is call the file with a program. Call it with bash or sh as suggested in the comment:

echo shell_exec('sh /shell_file.sh');

另一种选择可能是:

$contents = file_get_contents('/shell_file.sh');
echo shell_exec($contents);

不过我认为第一个选项会更好.

I think the first option would be better however.