首页 > 解决方案 > Mess with response Values: php->system->bash->python3

问题描述

I'm in trouble with response Values of a phyton script (face_detection).

If I run it directly in the console, everything works pretty well. If I run it as Part of a shell script, no response apear.

I already checked: 1.) image and scripts are usable by user www-data (at the end it should run as system-request from php). I checked it by sudo -u www-data ..

2.) Also also checked a much simpler command ("ls -l $1"), which brings the expected reponse. So only the python script doesnt work (as sub from bash script).

Now, I have NO Idea what else may be wrong in my code. Any Help would be very apreciated!

Regards Rene´

Some Background info:
Ubuntu 14.4, Kernel 3.13.0-24-generic
PHP 5.5.9-1ubuntu4.26
GNU bash, version 4.3.8(1)-release
face_recognise (https://github.com/ageitgey/face_recognition) V 1.2.3

on terminal:

/usr/local/bin/face_detection /var/www/1545249278.jpg

response is:

/var/www/1545249278.jpg,166,879,701,344 (= correct)

via bash-script:

#!/bin/bash
facePosition=`/bin/bash -c \"/usr/bin/python3 /usr/local/bin/face_detection $1\"`
printf $facePosition

response is: (None/empty = wrong)

I also checked this variations:

facePosition=`/bin/bash -c \"/usr/local/bin/face_detection $1 | /usr/bin/cut -d ',' -f2\"`
facePosition=`/bin/bash -c \"/usr/bin/python3 /usr/local/bin/face_detection $1\"`
facePosition=`env python3 /usr/local/bin/face_detection $1`

标签: python-3.xbash

解决方案


推荐阅读