I have some problem with php function exec. I'm trying to execute Code: exec("whoami"); echo exec("whoami"); .... but, I do not "receive" anything. Also I should use sudo. I have /root/start, /root/stop Code: #!/bin/sh #touch /var/lock/subsys/local # Firewall za port forward iptables -I FORWARD -p tcp -s $1 -d 192.168.168.2 -j ACCEPT I should execute from php: Code: exec("sudo /root/start ".$_SERVER['REMOTE_ADDR']); So... exec do not work, and how to set "sudo with apache"
Exec is not returnung any output. Please take a look in the php documentation, there are other functions like system and passthru that give you the output back.
For example shell_exec: Code: [COLOR=#000000] [COLOR=#0000BB]<?php $output [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]shell_exec[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]'ls -lah'[/COLOR][COLOR=#007700]); echo [/COLOR][COLOR=#DD0000]"<pre>$output</pre>"[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]?>[/COLOR] [/COLOR] Functions mentioned in this thread are often blocked by admins because they can be dangerous for the server. It's ok as long as You run them on Your own server without such restrictions.
Create a test page in document_root with <?php phpinfo(); ?> as the content and look for "disable_functions" in "PHP Core" section after opening it in the browser. It contains the names of blocked functions.