Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP DNS lookup script not executing shell command and writing DNS loopup results as expected
    primarykey
    data
    text
    <p>I'm thinking I'm close on this script. I'm now only able to get one line of domain name stuff written out to an output file. ideally, I want all my array fields written out for all the arrays returned:</p> <pre><code>function getDNS(){ if(file_exists($outputFile)){ unlink($outputFile); } $outputFile = 'DNS-Output.csv'; $inputFile = fopen('DNS-input.csv','r'); $output = NULL; //make sure we loop through to end of file contents $newOutput = 'Domain, IP Address, Exiration Date, Record Type, TTL, Cloud' . PHP_EOL; $output .= $newOutput; while (!feof($inputFile)) { $line = fgets($inputFile, 4096); $array = explode(",",$line); $result = dns_get_record($array[0], DNS_A + DNS_SOA); // get DNS info if ( ! is_array( $result )){ $results = explode(",",$result); } print_r($result); $whois = shell_exec("whois " . $result[0]['ip'] . " | grep" . " NetName"); $whois = preg_split("/[\s,]+/", $whois); if ( ! is_array( $whois )){ $result = explode(",",$whois); } //if array if ( is_array($whois)){ $whois[0]['host'].", " . PHP_EOL; // Domain Name //print_r($whois); } foreach ($whois as $record) { $output .= $record; /* $output .= $record['host'].", " . // Domain Name $record['ip'].", ". // IP Address $record['type'].", ". // Type of Record $record['minimum-ttl'].", ".PHP_EOL; // Minimum TTL */ } file_put_contents($outputFile, $output); // Create CSV File } //file_put_contents($outputFile, $output); // Create CSV File fclose($inputFile); } </code></pre> <p>getDNS(); </p> <p>And here is an example line from the input csv file that I'm doing the lookup off of....</p> <pre><code>somedomain.COM,.com,9/14/06 19:03,9/14/12 19:03,Active,Public,Locked,"ns31.domaincontrol.com(), ns32.domaincontrol.com()",, </code></pre> <p>Looking for the best way to now write the array elements out to their appropriate columns in a csv output file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload