What's Up?

OK, So I'm making a small batch script, That retrieves the IP of a website, And put it into a variable so we can use it later on. The problem is how do I get the IP of the website into a varible? The way I was going was

ping site.com >pinged.txt

But then your left with lots of text to wade through to get the IP.

Anyone know?

Thanks Bye!

This post is 2 days old, so I hope this helps...

There are some commands that are actually made for this! Try "host" or "nslookup". Your results will be much faster and easier to parse than ping.

-G

`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`

Okay, this thread is long dead, but this is for pratsgl:

The original poster was looking for a way to resolve a hostname to an ip address.
Your script works great for getting the LOCAL ip address!

Did you know that you can do all of that parsing in awk, without using grep and sed? Try something like this to consolidate those 4 commands down to just 2: ifconfig eth0|awk '/inet addr/ {split ($2,A,":"); print A[2]}'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.