Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
10-20-2010, 08:14 AM
|
#1
|
LQ Newbie
Registered: Oct 2010
Posts: 9
Rep:
|
How to get the ip address of host in linux with using of host and nslookup command
hi,
HOW TO GET THE IP ADDRESS OF HOST IN LINUX WITH USING OF HOST AND NSLOOKUP COMMAND and after getting the ip address how to assign it in the variable
|
|
|
10-20-2010, 08:27 AM
|
#2
|
Senior Member
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
|
Quote:
host=`host $(hostname)`
IP=$(echo $host | cut -d " " -f 4)
|
Cheers
|
|
|
10-20-2010, 08:46 AM
|
#3
|
LQ Newbie
Registered: Oct 2010
Posts: 9
Original Poster
Rep:
|
Thanks for your solution but one problem is coming when iam writing echo $IP it is not displaying the ip address of host
for this problem what is the solution
|
|
|
10-20-2010, 09:00 AM
|
#4
|
Member
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Rep:
|
rofl, best fix ever ;D
Try ifconfig
Oh and stop pasting your homework ;D
Wait, with, or without?
|
|
|
10-23-2010, 10:12 PM
|
#5
|
Senior Member
Registered: Sep 2003
Posts: 1,091
Rep:
|
IP=`host test.com | sed "s/^.* \([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}\).*/\1/"`
echo $IP
If it's homework.... I wouldn't use my suggestion without understanding it fully... If i were the teacher I would ask you to explain it
|
|
|
All times are GMT -5. The time now is 05:06 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|