problem with external command.
| From: | Jeremy Russell | Date: | Mon, 22 Sep 2003 17:14:00 +0000 |
| Subject: | problem with external command. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-163506@lists.php.net to get a copy of this message | ||
Hello list... Im fighting a losing battle here..
I'm needing help!
Everything seems to work fine with this function except that when the
command runs and is to populate the "$scan_result" field. It doesn't Im
not sure why either. I also get an "End of file unexepected" error in
my apache logs as well.
Anybody have any advice.
On top of the exec() function I've also tried shell_exec(), system(),
and even backtic's ``. I'm stumped... I'm not sure where to go with
this.
$nmap = "/usr/local/bin/nmap"; /* path to nmap program */
$nmap_opt = "-sT -sU -sR -O "; /* Nmap command line options */
$scan_log = "/usr/local/pub/tftp/scan.log"; /* scanner log file */
if( $attempts == 4 )
scanner($nmap,$nmap_opt,$ipaddr,$scan_log,$echo,$mail);
function scanner($scan,$opt,$ip,$log,$echo,$mail) {
$cmd = "$scan $opt $ip <br>";
print "This is the command: <br> $cmd<br><br>\n";
$scan_result = exec("$cmd");
print "This should be the scan : <br> $scan_result<br>";
$filename = "$log";
$fileid = fopen("$filename","a");
fputs($fileid,"$scan_result\n");
fclose($fileid);
//$mail_result =`$echo $scan_result | $mail -s "Hostile Node"
$admin`;
} /* end scanner() */
Jeremy Russell
Network Administrator, CNI
580.235.2377