Script execution when a registered phone makes a call

I asked a similar question earlier but I have a somewhat different requirement now.

I have a SIP enabled cell phone that is using a SIP application to register with Asterisk. I have configured 2 users accounts (6000 and 6001 )under Asterisk and they are configured as SIP type phones. I also have voicemail on extension 6999.

I want to execute a script when one of the users makes a call to the other user or to voicemail. I do have something in the “extensions.conf” file that only works some of the time. The entry is under “default” and looks like this:

SCRIPTDIR = /etc/asterisk/scripts

[default]
exten = o,1,
exten = s,1,System(${SCRIPTDIR}/winHello.sh ${CALLERID(num)})
exten = 6999,1,System(${SCRIPTDIR}/winHello.sh ${CALLERID(num)})
exten = 6999,2,VoiceMailMain(${CALLERID(num)}@default)

This was working badly until I did some changes and now it does not work at all.

The script “winHello.sh” just puts up a window (using zenity) that displays the callers extension number. It would be nice to display the entire SIP address (URI) though.

Cheers!!