• 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: Karthikeyan M <email@hidden>
  • Date: Tue, 07 Dec 2010 23:26:03 +0530

Thanks for the replies.

We use VBScript in Windows for the list of hostnames. We will list the hostnames in the textfile in the same folder of script and run the VBScript. The output will be in Excel with status as "offline" or "Online"

I am not sure this can be done on Mac.

Regards,
Karthik
 

On 07/12/10 10:47 PM, Steve Thompson wrote:

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: "Stockly, Ed" <email@hidden>
References: 
 >Script to Ping the list of IP/Hostnames and export it in a file (From: Karthikeyan M <email@hidden>)
 >Re: Script to Ping the list of IP/Hostnames and export it in a file (From: Steve Thompson <email@hidden>)

  • Prev by Date: Re: Script to Ping the list of IP/Hostnames and export it in a file
  • Next by Date: Re: text 1 thru the result
  • 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