Asterisk Externnotify in voicemail.conf not running the assigned script

Using asterisk 1.4.25.    In the voicemail.conf file we assign a script to the externnotify parameter so that this script would execute whenever a voicemail is left.    The script simple will turn on the message waiting indicator on cisco phones (for testing purposes we have it just echoing text into a file).  

Manually, the script runs.  And turns on the MWI on the phones.  

From the conf file, it does not.  

Asterisk is running as root and we test the file as root as well.  

Suggestions on why the script is not executing are welcome.

If you need additional info, please post on what you would liek to see.
LVL 33
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ron MalmsteadInformation Services ManagerCommented:
Can you post the voicemail.conf file ?...excluding security sensitive info of course.
Ron MalmsteadInformation Services ManagerCommented:
Also, did you do a "reload" after making the changes to voicemail.conf ?
MikeKaneAuthor Commented:
Attached is the file.    

You'll notice the call is for:


Here is the called script:

echo $3, $(date +%M%S) >> outfile
if [ $3 -gt 0 ]; then

cat < /var/spool/asterisk/1$2$1
Channel: Local/2315700
MaxRetries: 1
# Retry in 2 min
RetryTime: 120
WaitTime: 45

Context: default
Extension: wait
Priority: 1


        mv /var/spool/asterisk/1$2$1 /var/spool/asterisk/outgoing


CALLFILE=$(cat <<-EOF1
Channel: Local/2305700
MaxRetries: 1
# Retry in 2 min
RetryTime: 120
WaitTime: 45

Context: default
Extension: wait
Priority: 1


       echo "$CALLFILE" >> "/var/spool/asterisk/outgoing"/$(date +%Y%mNaVI%M%S)


; Voicemail Configuration
; NOTE: Asterisk has to edit this file to change a user's password.  This does
; not currently work with the "#include <file>" directive for Asterisk
; configuration files, nor when using realtime static configuration.
; Do not use them with this configuration file.
; Formats for writing Voicemail.  Note that when using IMAP storage for
; voicemail, only the first format specified will be used.
; If you change the list of formats that you record voicemail in
; when you have mailboxes that contain messages, you _MUST_ absolutely
; manually go through those mailboxes and convert/delete/add the
; the message files so that they appear to have been stored using
; your new format list. If you don't do this, very unpleasant
; things may happen to your users while they are retrieving and
; manipulating their voicemail.
; In other words: don't change the format list on a production system
; unless you are _VERY_  sure that you know what you are doing and are
; prepared for the consequences.
; Who the e-mail notification should appear to come from
; Should the email contain the voicemail as an attachment
; Maximum number of messages per folder.  If not specified, a default value
; (100) is used.  Maximum value for this option is 9999.
; Maximum length of a voicemail message in seconds
; Minimum length of a voicemail message in seconds for the message to be kept
; The default is no minimum.
; Maximum length of greetings in seconds
; How many milliseconds to skip forward/back when rew/ff in message playback
; How many seconds of silence before we end the recording
; Silence threshold (what we consider silence: the lower, the more sensitive)
; Max number of failed login attempts
; User context is where entries from users.conf are registered.  The
; default value is 'default'
; If you need to have an external program, i.e. /usr/bin/myapp
; called when a voicemail is left, delivered, or your voicemailbox
; is checked, uncomment this.  It can also be set to 'smdi' to use
; smdi for external notification.  If it is 'smdi', smdiport should
; be set to a valid port as specified in smdi.conf.
; If you need to have an external program, i.e. /usr/bin/myapp
; called when a voicemail password is changed, uncomment this:
; For the directory, you can override the intro file if you want
; The character set for voicemail messages can be specified here
; The ADSI feature descriptor number to download to
; The ADSI security lock code
; The ADSI voicemail application version number.
; Skip the "[PBX]:" string from the message title
; Change the From: string
;fromstring=The Asterisk PBX
; Permit finding entries for forward/compose from the directory
; Voicemail can be stored in a database using the ODBC driver.
; The value of odbcstorage is the database connection configured
; in res_odbc.conf.
; The default table for ODBC voicemail storage is voicemessages.
; Change the from, body and/or subject, variables:
; Additionally, on forwarded messages, you have the variables:
; You can select between two variables by using dialplan functions, e.g.
; Note: The emailbody config row can only be up to 512 characters due to a
;       limitation in the Asterisk configuration subsystem.
;emailsubject=[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}
; The following definition is very close to the default, but the default shows
; just the CIDNAME, if it is not null, otherwise just the CIDNUM, or "an unknown
; caller", if they are both null.
;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}, so you might\nwant to check it when you get a chance.  Thanks!\n\n\t\t\t\t--Asterisk\n
emailsubject=[Villalago House] New Voicemail, number ${VM_MSGNUM}
emailbody=A new voicemail was just ${IF($["${VM_CIDNUM}" = "${ORIG_VM_CIDNUM}"]?left:forwarded)} for you at the ${VM_NAME}.\n\n\tMessage Details:\n\n\t\tCaller Name:\t\t${VM_CIDNAME}\n\t\tCaller Number:\t${VM_CIDNUM}\n\t\tMsg Duration:\t${VM_DUR}\n\t\tDate:\t\t\t\t\t${VM_DATE}\n
; Note: ${IF()} strips spacing at the beginning and end of its true and false
; values, so a newline cannot be placed at either location.  The word 'so' is
; therefore duplicated, in order for the newline to be interpreted correctly.
;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just ${IF($["${VM_CIDNUM}" = "${ORIG_VM_CIDNUM}"]?left:forwarded)} a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE},\n${IF($["${VM_CIDNUM}" = "${ORIG_VM_CIDNUM}"]?so:(originally sent by ${ORIG_VM_CALLERID} on ${ORIG_VM_DATE})\nso)} you might want to check it when you get a chance.  Thanks!\n\n\t\t\t\t--Asterisk\n
; You can also change the Pager From: string, the pager body and/or subject.
; The above defined variables also can be used here
;pagerfromstring=The Asterisk PBX
;pagersubject=New VM
;pagerbody=New ${VM_DUR} long msg in box ${VM_MAILBOX}\nfrom ${VM_CALLERID}, on ${VM_DATE}
; Set the date format on outgoing mails. Valid arguments can be found on the
; strftime(3) man page
; Default
emaildateformat=%A, %B %d, %Y at %r
; 24h date format
;emaildateformat=%A, %d %B %Y at %H:%M:%S
; You can override the default program to send e-mail if you wish, too
;mailcmd=/usr/sbin/sendmail -t
; Users may be located in different timezones, or may have different
; message announcements for their introductory message when they enter
; the voicemail system. Set the message and the timezone each user
; hears here. Set the user into one of these zones with the tz= attribute
; in the options field of the mailbox. Of course, language substitution
; still applies here so you may have several directory trees that have
; alternate language choices.
; Look in /usr/share/zoneinfo/ for names of timezones.
; Look at the manual page for strftime for a quick tutorial on how the
; variable substitution is done on the values below.
; Supported values:
; 'filename'    filename of a soundfile (single ticks around the filename
;               required)
; ${VAR}        variable substitution
; A or a        Day of week (Saturday, Sunday, ...)
; B or b or h   Month name (January, February, ...)
; d or e        numeric day of month (first, second, ..., thirty-first)
; Y             Year
; I or l        Hour, 12 hour clock
; H             Hour, 24 hour clock (single digit hours preceded by "oh")
; k             Hour, 24 hour clock (single digit hours NOT preceded by "oh")
; M             Minute, with 00 pronounced as "o'clock"
; N             Minute, with 00 pronounced as "hundred" (US military time)
; P or p        AM or PM
; Q             "today", "yesterday" or ABdY
;               (*note: not standard strftime value)
; q             "" (for today), "yesterday", weekday, or ABdY
;               (*note: not standard strftime value)
; R             24 hour time, including minute
; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options>
; if the e-mail is specified, a message will be sent when a message is
; received, to the given mailbox. If pager is specified, a message will be
; sent there as well. If the password is prefixed by '-', then it is
; considered to be unchangeable.
; Advanced options example is extension 4069
; NOTE: All options can be expressed globally in the general section, and
; overridden in the per-mailbox settings, unless listed otherwise.
; tz=central            ; Timezone from zonemessages below. Irrelevant if envelope=no.
; attach=yes            ; Attach the voicemail to the notification email *NOT* the pager email
; attachfmt=wav49       ; Which format to attach to the email.  Normally this is the
                        ; first format specified in the format parameter above, but this
                        ; option lets you customize the format sent to particular mailboxes.
                        ; Useful if Windows users want wav49, but Linux users want gsm.
                        ; [per-mailbox only]
; saycid=yes            ; Say the caller id information before the message. If not described,
                        ;     or set to no, it will be in the envelope
; cidinternalcontexts=intern    ; Internal Context for Name Playback instead of
                        ; extension digits when saying caller id.
; sayduration=no        ; Turn on/off the duration information before the message. [ON by default]
; saydurationm=2        ; Specify the minimum duration to say. Default is 2 minutes
; dialout=fromvm ; Context to dial out from [option 4 from mailbox's advanced menu].
                 ; If not specified, option 4 will not be listed and dialing out
                 ; from within VoiceMailMain() will not be permitted.
sendvoicemail=no ; Allow the user to compose and send a voicemail while inside
                  ; VoiceMailMain() [option 5 from mailbox's advanced menu].
                  ; If set to 'no', option 5 will not be listed.
; searchcontexts=yes    ; Current default behavior is to search only the default context
                        ; if one is not specified.  The older behavior was to search all contexts.
                        ; This option restores the old behavior [DEFAULT=no]
                        ; Note: If you have this option enabled, then you will be required to have
                        ; unique mailbox names across all contexts. Otherwise, an ambiguity is created
                        ; since it is impossible to know which mailbox to retrieve when one is requested.
; callback=fromvm       ; Context to call back from
                        ;     if not listed, calling the sender back will not be permitted
; exitcontext=fromvm    ; Context to go to on user exit such as * or 0
                        ;     The default is the current context.
; review=yes            ; Allow sender to review/rerecord their message before saving it [OFF by default
; operator=yes      ; Allow sender to hit 0 before/after/during leaving a voicemail to
                    ; reach an operator.  This option REQUIRES an 'o' extension in the
                    ; same context (or in exitcontext, if set), as that is where the
                    ; 0 key will send you.  [OFF by default]
; envelope=no           ; Turn on/off envelope playback before message playback. [ON by default]
                        ;     This does NOT affect option 3,3 from the advanced options menu
; delete=yes            ; After notification, the voicemail is deleted from the server. [per-mailbox only]
                        ;     This is intended for use with users who wish to receive their
                        ;     voicemail ONLY by email. Note:  "deletevoicemail" is provided as an
                        ;     equivalent option for Realtime configuration.
; volgain=0.0           ; Emails bearing the voicemail may arrive in a volume too
                        ;     quiet to be heard.  This parameter allows you to specify how
                        ;     much gain to add to the message when sending a voicemail.
                        ;     NOTE: sox must be installed for this option to work.
; nextaftercmd=yes      ; Skips to the next message after hitting 7 or 9 to delete/save current message.
                        ;     [global option only at this time]
; forcename=yes         ; Forces a new user to record their name.  A new user is
                        ;     determined by the password being the same as
                        ;     the mailbox number.  The default is "no".
; forcegreetings=no     ; This is the same as forcename, except for recording
                        ;     greetings.  The default is "no".
; hidefromdir=yes       ; Hide this mailbox from the directory produced by app_directory
                        ;     The default is "no".
;tempgreetwarn=yes      ; Remind the user that their temporary greeting is set
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
1234 => 4242,Example Mailbox,root@localhost
;4200 => 9855,Mark Spencer,,,attach=no||tz=central|maxmsg=10
;4300 => 3456,Ben Rigas,
;4310 => -5432,Sales,
;4069 => 6522,Matt Brooks,,,|tz=central|attach=yes|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes|sayduration=yes|saydurationm=1
;4073 => 1099,Bianca Paige,,,delete=1
;4110 => 3443,Rob Flynn,
;4235 => 1234,Jim Holmes,jim@astricon.ips,,Tz=european
; Mailboxes may be organized into multiple contexts for
; voicemail virtualhosting
5700 => 2580,Villa**** House,it@o******.com
;The intro can be customized on a per-context basis
1234 => 5678,Company2 User,root@localhost

Open in new window

Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Ron MalmsteadInformation Services ManagerCommented:
I noticed there is no file extension...

Did you try ....
MikeKaneAuthor Commented:
Yep.  Our first attempts used '' as the script.    No difference.  

Everything with the script works when executed outside of asterisk.   Its just not getting called from asterisk when the new voicemail arrives....  
MikeKaneAuthor Commented:
Is there any detailed logging available in asterisk aside from the default /var/log stuff.    We need to see if the file is even attempting to run.  
Ron MalmsteadInformation Services ManagerCommented:
I'm testing this on my box, and i'm having the exact same issue....

It simply doesn't get executed.
I'm also running the same version you are....on CentOS.

Ron MalmsteadInformation Services ManagerCommented:
I opened a ticket with digium on this.

Waiting for response.
Ron MalmsteadInformation Services ManagerCommented:
Ok,... I GOT IT WORKING.....

I have  absolutely no idea why this makes any difference.... but I put my script in /root/

Echo "TEST" > /root/testfile

....testfile was created after leaving a message.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MikeKaneAuthor Commented:
Well, it is still odd.    Using your suggestion we found that having the script go to /tmp first then mv the file to the outgoing folder seems to work for us.  

I can't explain why it likes /tmp and not the other dirs we tried since they all had the same security.    

But whatever, its working for now.  

Thanks for the tip.
Ron MalmsteadInformation Services ManagerCommented:
I talked to someone else on a digium forum, who also used the tmp dir, and it worked for them too.

I think the wiki needs to be updated.

If I had to guess I would say it's due to OS security, ..permissions for applications executing scripts from system directories ?..who knows....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IP Telephony

From novice to tech pro — start learning today.