Script Stalling When Waiting for Curl

I have a script that is sending commands via curl when I press buttons. I’ve redirected the curl output to > /dev/null as per Apple documentation so it will move on to the next object in the script and not wait for the curl process to finish.

My problem is I’m still getting delay from the button press. I’m controlling a relay box and I know it can handle commands back to back faster then my script is issuing them because I can issue them fast using 2 terminal windows. I’m being picky about the delay because this is controlling the panning of a camera. With the delay as it is now the relays stay closed for about a second so there is no way to make fine adjustments on the camera position.

Here’s part of the script. I’m I missing something in getting the script to issue a Curl command via Mouse Down and then issue the Mouse Up part of the script soon as I let go of the button? I’ve made a test using the touch command, test.txt for the down and test1.txt for the up and both files appear instantly after pressing the button. I’m guessing something with Curl is stalling things.


on mouse down theObject event theEvent
if the name of theObject is equal to "left" then
do shell script "/usr/bin/curl http://admin:12345678@192.168.100.20/SetIO?p61=0 > /dev/null"
end mouse down

on mouse up theObject event theEvent
if the name of theObject is equal to "left" then
do shell script "/usr/bin/curl http://admin:12345678@192.168.100.20/SetIO?p61=1 > /dev/null"
end mouse up

Here I go answering my questions again. :slight_smile: I guess I should research even more before posting.

I found this in an older post.

> /dev/null 2>&1 &

It appears I needed to send the errors to null as well and then the & detaching the shell process. I haven’t been able to test on my relay box yet since it’s still at work but the buttons are very responsive when using a dummy host that would hang because curl was trying to connect.