Re: Script to Ping the list of IP/Hostnames and export it in a file
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: suthercd <email@hidden>
- Date: Tue, 07 Dec 2010 17:14:40 +0000 (GMT)
On Dec 07, 2010, at 09:30 AM, Karthikeyan M <email@hidden> wrote:
Hi,
I am very new to Apple script. Does anyone can share shell/Apple script
to ping the list of hostname/IP address and provide the output in CSV/txt?
Regards,
Karthikeyan M
_______________________________________________
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
This script creates a file on the Desktop with PING results. The script runs PING for each item in the hostList and then calls a handler which writes the result to the Desktop file.
It is useful to put the ping command and its parameters in a variable so that the script is more easily read and edited Note there is a space after the '-q' parameter to delimit the command and its parameters from the IP/URL targeted.
HTH
Craig Sutherland
set theCommand to "ping -o -q " --parameters specify 1 ping and quiet mode for more succinct response
set hostList to {"www.google.com", "192.168.2.1", "www.yahoo.com"}
repeat with aHost in hostList
set pingResult to do shell script theCommand & aHost
my writeData(pingResult)
end repeat
on writeData(theData)
set thePath to (path to desktop as Unicode text) & "ping.txt"
try
set f to (open for access file thePath with write permission)
write theData to f as «class utf8» starting at eof
close access f
on error
close access f
end try
end writeData
_______________________________________________
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