I got a problem with the shell_exec
php function, here is a example code:
$output = shell_exec('nmap -PS80 -n -oG - --send-ip 11.11.11.11');
if ( $output )
{
echo "Output found...";
}
else
{
var_dump( $output );
}
It does return: NULL
, but when I change the shell_exec
command to the following:
$output = shell_exec('echo 1');
then the output is: Output found...
so its working properly, and there is no problems with permissions or safe mode (which is off , by the way).
It is having a problems with execute the nmap
command. I've check that command in the shell command line in putty and its working properly:
# nmap -PS80 -n -oG - --send-ip 11.11.11.11
# Nmap 5.61TEST2 scan initiated Tue Feb 28 13:55:41 2012 as: nmap -PS80 -n -oG - --send-ip 11.11.11.11
# Nmap done at Tue Feb 28 13:55:43 2012 -- 1 IP address (0 hosts up) scanned in 0.04 seconds
So where is the problem?
You might want to resort to
exec()
instead, which gives you greater error diagnostics:Try to specify full path to nmap like
/usr/local/bin/nmap
. PHP might not know about nmap location. Enjoy!