简体   繁体   English

php function pcntl_exec(“/bin/sh”, “/bin/sh”)

[英]php function pcntl_exec(“/bin/sh”, “/bin/sh”)

According to the php manual , the function pcntl_exec is equal to the syscall execve .根据php 手册, function pcntl_exec等于系统调用execve

So I think所以我认为

pcntl_exec("/bin/sh", ["/bin/sh"]);

should do the same thing like:应该做同样的事情,比如:

#!/bin/sh
/bin/sh

However I got the result: # /bin/sh: 1: Syntax error: ")" unexpected但是我得到了结果: # /bin/sh: 1: Syntax error: ")" unexpected

Why?为什么?

php version 7.4.3(cli) Zend Engine v3.4.0 php 版本7.4.3(cli) Zend Engine v3.4.0

This is incorrect:这是不正确的:

should do the same thing like:应该做同样的事情,比如:

 #!/bin/sh /bin/sh

It is equivalent to running the command /bin/sh /bin/sh which will attempt to interpret /bin/sh as a shell script.它等效于运行命令/bin/sh /bin/sh ,它将尝试将/bin/sh解释为 shell 脚本。

The actual equivalent of what you want would be:您想要的实际等价物是:

pcntl_exec("/bin/sh", ["-c", "/bin/sh"]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM