PHP exec() and shell_exec() functions cause hanging
#1
PHP exec() and shell_exec() functions cause hanging
Hi guys,

I'm having a problem with the PHP functions exec() and shell_exec(). Nothing in the php after the exec will execute. Even a simple 
PHP Code:
exec("echo 'hello'"); 

causes it.

Things that could be the problem, and what I've tried:
  • The apache user may not have sufficient permissions. Though as the root user I did run 
    sudo -H -u www-data bash -c 'echo "I am $USER, with uid $UID"'
which worked fine.
  • The exec functions may still be blocked somehow, even though I have already erased everything in the disable_functions entry in  /etc/php5/apache2/php.ini, and restarted apache2:
[Image: 2be9c41387.png]

I've also tried including 'sudo', like exec("sudo echo 'hello'"); , but it didn't make a difference.

The problem only occurs on my DigitalOcean server that's running Ubuntu 12.04 with Sentora. On my local copy of the website, which is ran on Windows 10, I don't have this problem.

Edit: I'm aware that it's not great to use exec() as it leaves the website vulnerable. The reason why I'm using it is because my website works like this: User uploads an image, and a program written in C++ (on the server) runs on the image, extracting information. The information is then stored in a database, and the image is deleted. So, I use exec() to get the C++ program to run on the image. Is there a smarter way to go about doing this?

Any help would be appreciated. Thank you for your time!
Reply


Messages In This Thread
PHP exec() and shell_exec() functions cause hanging - by steve_nf - 08-10-2015, 02:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
shell_exec worksmarter 1 5 ,047 01-16-2018, 01:39 AM
Last Post: Ron-e
PHP exec disabled - problem enabling. asobiek 2 9 ,492 07-07-2016, 05:33 AM
Last Post: Me.B
PHP disable functions sunardi 9 38 ,630 04-11-2016, 07:53 PM
Last Post: Kevvo

Forum Jump:


Users browsing this thread: 1 Guest(s)