ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i'd like to parse out the ip address of a given hostname from nslookup or dig. even better would be a way to get nslookup just to print out the ip only (did a man nslookup but didnt see the option).
here is what i know:
nslookup hostname -sil will print out 7 lines:
1. Server: IP.OF.Nameserver
2. Address: IP.OF.Nameserver:portnumber
3.Blank Line
4.Non-authoritative answer:
5.Name: hostname
6.Address: IP.OF.Host
7.Blank Line
knowing this, the script would only have to grab the 6th line (5 if you count from 0) and then the second word of that line (if you delimit based on white space).
I can do this in Java if the information from nslookup is stored to a file but that's is not very efficient at all because after i get the ip i have to do some DNS stuff with it to update an IP address.
i'd rather not use perl, but i'll take any suggestions or code slices anyone is willing to give me for this. right now im looking into some shell scripting but i thought i'd ask here in the meantime.
Thanks,
Robert
Last edited by Robert0380; 08-24-2003 at 04:43 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.