C
C
Ciscoridze2016-04-01 09:33:11
linux
Ciscoridze, 2016-04-01 09:33:11

How to ping a group of hosts with bash on a domain name and write their IP to a file?

There is a file with the domain names of the servers, you need to ping them and write the addresses to the file
Machine name - IP address.
How to do it in bash? (or python/ruby)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shetani, 2016-04-01
@Shetani

to find out the IP it is better to use the host command

while read p || ; do                                                 
     host ${p} >> result.txt                                                        
done < hosts.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question