Saturday 1 June 2013

Ping server/domain, capture IP (help)

Ping server/domain, capture IP (help)

I have a question that I cant seem to find an answer for. With windows, you could ping a given domain name, and capture the ip as a variable, even if no reply was recieved. I believe the command looked something like this:
-ping domain.com
for /f "tokens=1,2 delims=[]" %%A in ('ping /n 1 /w 1 domain.com ^| find "Pinging"') do set ipaddress=%%B"
This is basically what I am trying to do, but within a bash script rather than a batch file. I've stumbled across alot of questions that are Really close, but not quite what I am looking for & I can't seem to figure out the best way to go about this. Any ideas?
ps: I'm still fairly new to linux and it's tools..

No comments:

Post a Comment