• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script to Ping the list of IP/Hostnames and export it in a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script to Ping the list of IP/Hostnames and export it in a file


  • Subject: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • From: Steve Thompson <email@hidden>
  • Date: Tue, 07 Dec 2010 17:17:12 +0000


On 7 Dec 2010, at 15:30, Karthikeyan M wrote:

Does anyone can share shell/Apple script to ping the list of hostname/IP address and provide the output in CSV/txt?

I'm so confused by this I'm going to bite. :-)

The output from ping is between 2 and c+1 lines of text:

$ ping -c1 www.apple.com
PING e3191.c.akamaiedge.net (2.19.157.15): 56 data bytes
64 bytes from 2.19.157.15: icmp_seq=0 ttl=58 time=1.797 ms

Not really much to convert to CSV. And if you want the output in a text file, no need to go near AppleScript

$ ping -c1 www.apple.com > output.txt
$ open output.txt 

To ping a range of IP addresses

for i in {1..254}; do ping -Q -n -c1 192.168.192.$i; done

Using AppleScript you could do something like this:

set resvar to ""
repeat with i from 190 to 200
set the_cmd to "ping -c1 192.168.199." & i
try
do shell script the_cmd
set resvar to resvar & the_cmd & " success" & return
on error
set resvar to resvar & the_cmd & " fail" & return
end try
end repeat

Result:

"ping -c1 192.168.199.190 success
ping -c1 192.168.199.191 success
ping -c1 192.168.199.192 success
ping -c1 192.168.199.193 success
ping -c1 192.168.199.194 fail
ping -c1 192.168.199.195 fail
ping -c1 192.168.199.196 fail
ping -c1 192.168.199.197 fail
ping -c1 192.168.199.198 fail
ping -c1 192.168.199.199 success
ping -c1 192.168.199.200 success
"

But not being clear on what you're trying to do, I can't give you any more than that!

Steve

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Script to Ping the list of IP/Hostnames and export it in a file
      • From: Karthikeyan M <email@hidden>
References: 
 >Script to Ping the list of IP/Hostnames and export it in a file (From: Karthikeyan M <email@hidden>)

  • Prev by Date: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • Next by Date: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • Previous by thread: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • Next by thread: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • Index(es):
    • Date
    • Thread