I believe that after a wan-event is triggered it doesn't mean that you already have wan access. Sometimes it takes a few seconds (or longer?) to actually have a working connection again. So immediately executing commands that rely on connectivity are probably not going to work. Try building in a...