Web Hosting Talk







View Full Version : List domains via ip address


Blueheaven
03-21-2010, 03:49 PM
Anyone know of any script that can list 100+ domains in a txt file
and then output the ip of those addresses?

Can be program or even linux bash script

Blueheaven
03-21-2010, 04:31 PM
I have found a good script to do this...
But now I just need to be able to either read a single page that has all of the domains, i.e a text file or a html page.
ad then output the domains with the ip next to them.

<?php
$ip = rtrim(`/usr/bin/dig $host A +short | /usr/bin/tail -1`);
?>

Blueheaven
03-21-2010, 04:57 PM
Using that code and google I've kind of made a script but it has errors and as this is my first day ever of php programming, I'm kind of lost.


<?php
$myFile = "http://url-with-domain-names.htm";
$fh =fopen($myfile,'r');
$data = fgets($fh);
fclose($fh);
$ip = rtrim(`/usr/bin/dig $data +short | /usr/bin/tail -1`);
echo $data;
?>

Any ideas where i'm going wrong?

jack369
03-21-2010, 05:06 PM
It looks like you need to replace "echo $data;" with "echo $ip;" on the second to last line.


<?php
$myFile = "url-with-domain-names";
$fh =fopen($myfile,'r');
$data = fgets($fh);
fclose($fh);
$ip = rtrim(`/usr/bin/dig $data +short | /usr/bin/tail -1`);
echo $ip;
?>

Jalal KH
03-21-2010, 05:13 PM
well, in this case you need to write the IP on the file, rather than using echo for it.

Blueheaven
03-21-2010, 05:22 PM
I'm getting these errors after making the changes discussed.
Warning: fgets(): supplied argument is not a valid stream resource in
Warning: fgets(): supplied argument is not a valid stream resource in on line 10h.root-servers.net.

I think the script is not right...

Blueheaven
03-21-2010, 06:19 PM
I fixed the errors but its not really doing what I need, which is to print out the ips of the domains...

What I've done is inserted the domains onto a text file. (like this)

http://www.hippocampe.info/
http://www.highlighthealth.info/
http://www.helpindex.co.uk/
http://www.helloindex.com/

Then called the file using this script

<?php
$myFile = ("http://automax.tv/1000-3000.txt");
$handle = fopen("http://automax.tv/1000-3000.txt","r");
$data = fgets($handle);
$ip = rtrim(`/usr/bin/dig -4 $data +short`);
echo $ip;
fclose($handle);
?>


However its printing out the full dig without +short and not printing out the ip either.
http://www.automax.tv/checkip2.php

If you enter dig -4 +short www.hippocampe.info it should give just the ip...

mattle
03-22-2010, 11:40 AM
Any ideas where i'm going wrong?

The biggest thing that I don't see is any return value checking/debugging.


if (! $handle = fopen(...)) die(...);

if (! $data = fgets($handle)) die(...);

echo "<pre>" . print_r($data, true) . "</pre>";
// etc.


That last echo will reveal the source of your frustration :) Or, read the manual for fgets, especially the definition of the length parameter.

Blueheaven
03-27-2010, 06:24 PM
Thanks very much for your help, with some help from some other programmers I've created a website that will help you check your domains.

I have tested with about 1000 and its working good.
Its free also.

http://www.massipchecker.com/index.php

web7689
04-01-2010, 10:53 AM
oh, cool. sounds like a nifty little service.