简体   繁体   中英

Commands working fine in putty but not using exec() in PHP

So I have installed shhavel's facerec ( https://github.com/shhavel/facerec ) on my VPS (Ubuntu 14.04.5) and it works perfectly fine when I use it from within putty:

facerec list
jenniferlawrence
emmawatson

However, from within PHP when using the exec() function, the only command that works is facerec -help, all other commands produce an error similar to the following:

facerec list 2>&1

Traceback (most recent call last):
File "/usr/local/bin/facerec", line 359, in 
sys.exit(__main__())
File "/usr/local/bin/facerec", line 356, in __main__
return args.func(args)
File "/usr/local/bin/facerec", line 159, in list
for subject in os.listdir(subjects_directory):
OSError: [Errno 2] No such file or directory: './subjects'

The PHP script:

exec('facerec list 2>&1', $output);
foreach($output as $string) {
    echo $string."<br>";
}

How do I approach fixing this problem?

Found the problem:

The "subjects"-folder was located in /root/ which the PHP script did not have the permission to access

Possible solutions:

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