I have built a program which involves pinging specified IP addresses to tell whether they are active or not.
repeat for IPaddress in allIPaddresses
try
do shell script "ping -o -t 1 -c 1 " & IPaddress
set goodIPs to (goodIPs & IPaddress) -- where goodIPs is a list of online IPs
end try
end repeat
The problem is that it will cycle through a lot of IPs if needed and the interface freezes up while it is pinging - so if you needed to hit the "Quit" button, you can't and Force Quitting is the only way to stop it. After searching around for how to run the command as a background process, I found the most common answer (eg https://discussions.apple.com/thread/323661?start=0&tstart=0) was to add:
> /dev/null 2>&1 &
or slight (but similar output) variations of that to the end of the shell command. But that involves sending the stderr away from the application, and since my program needs the stderr to tell if the ping was successful or not, this is not an option. Does anyone know how to keep stderr normal but move the command to a background process so that the interface works as normal?