What I try to achieve is that the dialog should output the IP adres that is in the list.
set ipList to {DNS1:"8.8.8.8", DNS2:"8.8.4.4"}
set input to "DNS1"
set output to input of ipList
display dialog output
it gives an error: error "input of {DNS1:\"8.8.8.8\", DNS2:\"8.8.4.4\"} kan niet worden opgevraagd. " number -1728 from input of {DNS1:"8.8.8.8", DNS2:"8.8.4.4"}
If I do:
set output to DNS1 of ipList
it works, so my guess I should do something with variable input.
I've been googling for some time now but I can't seem to find a hint. I'm pretty sure the answer is already somewhere on here but I can't seem to find it. Sorry for that.
UPDATE: I think I asked the question all wrong.
Let me retry, I have a list:
set ipList to {DNS1:"8.8.8.8", DNS2:"8.8.4.4"}
I would like to loop through the items. So have this coded with less code:
set IP_address to "8.8.8.8"
try
set ping to do shell script ("ping -c 2 " & IP_address & "| head -2 | tail -1 |cut -d = -f 4")
if ping contains "ms" then
set Output1 to "DNS 1 UP"
else if ping contains "timeout" then
set Output1 to "DNS 1 DOWN"
end if
end try
set IP_address to "8.8.4.4"
try
set ping to do shell script ("ping -c 2 " & IP_address & "| head -2 | tail -1 |cut -d = -f 4")
if ping contains "ms" then
set Output2 to "DNS 1 UP"
else if ping contains "timeout" then
set Output2 to "DNS 1 DOWN"
end if
end try
display dialog (Output1 & return & Output2) buttons {"OK"} default button 1 with title "Resultaat"
Again, I'm a newbie, I'm sorry