I am booting a Netboot Image with a MacMini 5.1, after the system is up a shell script calls a server via curl.

At the moment the Internet connection is up and running. I verify that doing a ping to the same server before using curl.

Every now and then it is not working properly. When it is not working the http get request never reaches the server. Since the ping worked before i think it might be a DNS problem.

If i use curl "manually" 2 time working 3rd time not... Its not easy to reproduce this error...

So i tried to add the IP to /etc/hosts and it is still not working properly every time.

What might cause this problem ?

2 Answers 2


Check the return value from curl. If there are problems you should get a non zero value. Something like this may work:

echo trying download . . .
until curl http://example.com/test.file ; do {
    echo something went wrong. retrying download . . .
}; done
echo file downloaded.

I found the same thing. It might be your internet provider. I just added a test for a successful connection, if failure sleep 5, then retry say a maximum of five times.

  • very intersting, do you also have a mac mini ? Apr 19, 2013 at 9:11
  • Yes for Mac Mini. I was using curl in a big script and would get failures after a certain point. Besides sporadic errors, I suspected my internet provider was tagging my IP for heavy usage and then shutting me down. What I did was release and renew my IP address before every run, and repeat the script three times, then use two out of three majority rules to provide the result.
    – user42890
    May 1, 2013 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .