I'm trying to make a DNS in Ubuntu and sometimes I have to use the dig command(I'm using test=system("dig www.google.com") How can I get the IPv4 from the return of the dig command to them be able to use it?
Asked
Active
Viewed 71 times
0
-
2Using `system`? You can't. Try [`popen`](http://man7.org/linux/man-pages/man3/popen.3.html) instead. – Some programmer dude Nov 24 '15 at 12:24
1 Answers
0
Do you mean "make a DNS lookup"? If so, try the functions gethostbyname
and gethostbyaddr
. This is much more efficient than dig
.
Or do you specifically want the output of dig
? If so, use popen()
.

abligh
- 24,573
- 4
- 47
- 84