Using PHP's exec Functions

Here I will create a function and pass it a IP Address.
I'll use alot of the what we learned so far;

  • Creating variables and assigning values to them
  • Creating a function
  • Creating an array
  • using echo to display data to the browser
  • Using the PHP exec function
function nmap_pc($nmapipaddr) {

$time=date("H:i:s");
$date=date("d-m-Y");
$nmap = "/usr/local/bin/nmap $nmapipaddr -sP";
$command = "$nmap";
echo "NMAP ran against:   $nmapipaddr ";
echo "<BR>";
echo "$date @  $time";
echo "<P>";
@exec($command, $dd, $result);
$dd[] = $dd -1;
$indexLimit = count($dd);
for($index=0; $index < $indexLimit; $index++) {
$orts = (" $dd[$index] ");
echo  (" $orts
"); } } nmap_pc($nmapipaddr);

>> Comments/FeedBack

 

This web site is prepared and maintained by Chauncey Thorn. The information contained in this site was valid at the time of posting. Chauncey Thorn assumes no liability for damages incurred directly or indirectly as a result of errors, omissions or discrepancies.

 
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002