简体   繁体   中英

Php shell_exec() not running python script

I am trying to run a python script from php code. I have followed other threads to see what I'm doing wrong, but i can't seem to find the problem.

$out = shell_exec(escapeshellcmd("/path/to/script/here/script.py arg1 arg2"));
echo $out;

As you might ask, yes, the script:

  1. has "#!/usr/bin/env python3" added
  2. has permission to be read and executed by group www-data (from output apachectl -S)
  3. is executable

At the same time, any other non-script command works just fine with shell_exec()

I tried your code, it is working fine for me. If there is some error, it must be logged in error.log file. eg I am using apache so my errors are logged in /var/log/apache2/error.log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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