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:
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
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