Using #exec to set externaddr in sip.conf

Today I was working on a system, and knowing that the system is going to get moved, and that often one of the things forgotten is to update the externaddr= option in sip.conf (when Asterisk is sitting behind NAT), I decided to put together a little script that returns the external IP address of the system. Using this script along with an #exec in the sip.conf file will make it so the address gets updated when the system is moved to the new physical location. I used the php5-curl package on Ubuntu. I used the example from this page for cURL: http://www.php.net/manual/en/curl.examples-basic.php

well I do enable it, but still doesn´t work….
In the asterisk console i can see this warning:
== Parsing ‘/var/tmp/exec.1302632385316731.1088866624’: == Found
[Apr 12 13:19:45] WARNING[2758]: config.c:1175 process_text_line: No ‘=’ (equal sign) in line 1 of /var/tmp/exec.1302632385316731.1088866624

I finally have the answer to the problem. The warning was because the directory where my script was saved has to have execute access for the user “asterisk”.
I tried with the permissions for the script, but then I notice that directory in which the script was saved, has to have execute access for “asterisk”. Then I change the owner of the script and the directory, to asterisk.asterisk and give permissions like this: d–x—— to the directory, and permisions like this: -r-x—— to the script, and problem solved…
I hope it will help someone else… 😀