LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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

Reply
 
LinkBack Search this Thread
Old 10-20-2010, 07:14 AM   #1
hussain.s
LQ Newbie
 
Registered: Oct 2010
Posts: 9

Rep: Reputation: 0
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
 
Old 10-20-2010, 07:27 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,435
Blog Entries: 11

Rep: Reputation: 181Reputation: 181
Quote:
host=`host $(hostname)`
IP=$(echo $host | cut -d " " -f 4)
Cheers
 
Old 10-20-2010, 07:46 AM   #3
hussain.s
LQ Newbie
 
Registered: Oct 2010
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 10-20-2010, 08:00 AM   #4
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
rofl, best fix ever ;D

Try ifconfig

Oh and stop pasting your homework ;D

Wait, with, or without?
 
Old 10-23-2010, 09:12 PM   #5
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,090

Rep: Reputation: 41
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] nslookup, host, dig not resolving entries in /etc/hosts MensaWater Linux - Networking 12 11-01-2012 08:25 AM
[SOLVED] ping / nslookup / host not working j66788 Linux - Networking 5 10-07-2009 05:52 PM
Inconsistent results using ping, dig, nslookup, whois, host steelaz Linux - Networking 3 04-05-2009 07:50 AM
(nslookup) vs (dig and host) emailssent Linux - Networking 7 10-06-2004 08:38 AM
Dig, host, nslookup? gsibble Arch 1 02-03-2004 01:02 PM


All times are GMT -5. The time now is 09:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration