Text2wave festival not working via nginx php exec
Asked Answered
R

3

10

I'm trying to run a shell command text2wave in PHP on a nginx server.

The problem is the command just exits silently without working as it should. It's also not displaying any errors.

Here's the code:

<?php
$result = `/usr/bin/text2wave --help`;
var_dump($result);

If I run the script via php command in shell ( as a normal user) it works as expected. However, If I run it via a http request through nginx the var_dump returns NULL ( there are also not logs in error log files)

Thanks for your help!

Rotman answered 17/7, 2013 at 12:17 Comment(5)
maybe because the php instance doesn't have permission to run the command, check the permissions and ownership of the executable text2waveMukerji
the permissions are -rwxr-xr-x. Same as the program festival which workes perfectly via nginx phpRotman
try to enable ini_set('display_errors','on') in the first line and see if it shows any thing.Mukerji
nope... no php errorsRotman
try using /usr/bin/text2wave --help 2>&1 and see if it shows any output.Mukerji
B
3

try:

<?php
function sys_cmd($cmd)
{   
    $hd = popen($cmd,"r") or die('function disabled');
    while (!feof($hd))
    {
        $rs .= fread($hd,1024);     
    }
    pclose($hd);
    return $rs;
}
echo sys_cmd('ls -l');
?>
Brownlee answered 3/3, 2014 at 11:57 Comment(1)
the script works with 'ls -l', but not with 'text2wave --help' ( nor normal usage of text2wave of course)Rotman
A
0

My guess would be that you've got shell execution disabled in the php.ini configuration file used by your web server.

Try opening /etc/php5/fpm/php.ini file, finding the disable_functions directive, and making sure that none of the following functions are present in the value of the directive: shell_exec,exec,passthru,system

Adiell answered 26/7, 2013 at 14:8 Comment(3)
Can you explain how that magically executes OP's $result = '/usr/bin/text2wave --help';? Look at it again — that's a (string) variable assignment, not a function. OP doesn't have to fix any configuration; instead, OP needs to correct his PHP code.Anissaanita
Oh, those are "backticks"! I thought those were formatting errors… (hits head against the wall) My bad; you're absolutely correct. Thanks for the heads-up. I've removed my incorrect answer accordingly. From my point of view, you'll get that bounty well deserved! On the other hand, looking at the fact that I didn't notice the difference between single-quotes and backticks, my "view" might not be the best to rely on. ;)Anissaanita
shell exec works. it doesn't work through nginx php running text2waveRotman
R
0

To anybody haing the same problem... I've managed to find out what the problem was. Well.. kind of.

I've switched to apache and it started working right away. So the solution is not to use nginx

I guess it had something to do with the way nginx ran php when doing exec commands...

Although it was a hard decision, I found no other solution but to change to apache... works well now

Rotman answered 12/3, 2014 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.