thanks for the responses, It was the fact that the user i was connecting as didnt have write permissions. That cant be changed so I just have a cron job execute the query write it into a file that ...