How to retrieve PHP exec() error responses?

后端 未结 7 1619
孤街浪徒
孤街浪徒 2020-12-15 03:42

Below is the command I tried executing, without success:

exec(\'ln -s \' . PLUGIN_DIR . \'/.htaccess \' . ABSPATH . \'/.htaccess\');

When y

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 04:02

    This in not a direct answer to your question, but is very useful, if you want to know what exactly happened by returned error code.

    If error code ($res), returned by command:

    exec('command', $out, $res);
    

    was in range 1-2, 126-165, 255, than it was returned by shell (eg. BASH) invoked from PHP (to execute your command). If returned code is not in this range, than it was returned by your command (not shell).

    See (for BASH error code descriptions)

    https://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/exitcodes.html

提交回复
热议问题