PHP shell_exec无法执行特定命令

时间:2017-10-20 14:50:48

标签: php shell centos scrapy plesk

我在CentOS 7上运行服务器,由Plesk 17管理。

我试图在脚本中通过shell_exec运行命令,但每次都失败。起初我认为这是一个权限/目录问题,但它似乎并非如此,因为命令在命令行中运行完全正常,同一用户在shell_exec中执行。 / p>

chdir("/var/www/vhosts/website.com/MyScraper");
$call = shell_exec("pwd & id -u -n & date & scrapy crawl crawler_name & date");
var_dump($call);

通过该调用,我看到了正确的路径,然后是当前用户(user1),日期日期,然后没有。这意味着scrapy命令不起作用,并且最后一个日期调用也不会执行(它是我知道scrapy命令崩溃的方式)。仅在shell_exec中运行scrapy cmd也不起作用。

我怎样才能让它发挥作用?从putty开始,完全相同的调用与来自同一目录的相同用户(user1)一起工作。

编辑:我从通话中得到了这个输出。

Traceback (most recent call last):
  File "/usr/bin/scrapy", line 11, in <module>
    sys.exit(execute())
  File "/usr/lib/python2.7/site-packages/scrapy/cmdline.py", line 128, in execute
    cmds = _get_commands_dict(settings, inproject)
  File "/usr/lib/python2.7/site-packages/scrapy/cmdline.py", line 46, in _get_commands_dict
    cmds = _get_commands_from_module('scrapy.commands', inproject)
  File "/usr/lib/python2.7/site-packages/scrapy/cmdline.py", line 29, in _get_commands_from_module
    for cmd in _iter_command_classes(module):
  File "/usr/lib/python2.7/site-packages/scrapy/cmdline.py", line 19, in _iter_command_classes
    for module in walk_modules(module_name):
  File "/usr/lib/python2.7/site-packages/scrapy/utils/misc.py", line 71, in walk_modules
    submod = import_module(fullpath)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/scrapy/commands/version.py", line 6, in <module>
    import OpenSSL
  File "/usr/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python2.7/site-packages/OpenSSL/crypto.py", line 16, in <module>
    from OpenSSL._util import (
  File "/usr/lib/python2.7/site-packages/OpenSSL/_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 13, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: /usr/lib64/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so: cannot enable executable stack as shared object requires: Permission denied

0 个答案:

没有答案