E911 Notification - Dashboard widget / Email / SMS text / Paging

I get the error too, but the dial plan executes fine I receive an email each time.

Well, still no joy on mine. It throws the error, text never gets sent out.

FOLLOW UP:

Changing it from “System” to “SHELL” also had the same error.

This is most certainly a bug; it shouldn’t be interpreting the line, just passing it to the OS.

Have you tried escaping the pipe character?

I did try escaping it… I"m going to try setting the command with a SET then executing it…

WOW… even if I SET the variable, then SHELL(variable), it STILL gives the same error.

ONE FINAL THING I could try doing… passing ${AMPUSER} and ${AMPUSERCID} as parameters, then have a bash script that accepts those parameters, and sends the mail.

What a complete PITA though…

At least then, it’s just calling a shell script and passing parameters to it.

One last suggestion:

Wrap the echo command in quotes and escape the quotes inside the system() function.

exten => s,1,ExecIf($["${OUTNUM}"=“xxxxx”]?System(“echo \“Ext ${AMPUSER} - ${AMPUSERCIDNAME} just placed a 911 emergency call on ${STRFTIME(%C%m%d%y%H%M)}\” | mailx -r \“[email protected]\” -s \“911 Alert from ext ${AMPUSER} - ${AMPUSERCIDNAME}\” [email protected]”))

The System() application use to be called on as System(command|args|args) now it is System(command), piping out to a command via System() is going to trigger that warning not error about having old syntax in your dialplan.

Personally, I feel this is one of those old methods (from way back in the day) that people just used for quick and dirty execution. I do something like this myself

exten => s,1,ExecIf($[“${OUTNUM}”=“xxxxx”]?System(/var/lib/scripts/911alert.php ${AMPUSER} ${AMPUSERCIDNAME} ${STRFTIME(%C%m%d%y%H%M)})

Allowing me more flexibility to compose the email, do any database or other actions and send the email to multiple people.

You could, of course, use your preferred language to do such a thing. Like I said though, echoing text out to the STDOUT and piping into another system program is rather antiquated. To me at least.

I resolved it by writing a little shell script and passing the {AMPUSER} and {AMPUSERCIDNAME} to it.

As far as piping being antiquated, so am I. XD I’ve been using some form of *NIX since 1986.

Old dogs… new tricks… etc.

So, final thoughts on this.

  1. Yes, you’re right… it throws a warning, not an error.
  2. I forgot that I pre-pend a 1 onto 10-digit calls, so it probably WOULD have worked, had I put the 1 in front of my test number.
  3. I ended up writing a little shell script and passing the parameters to it, which also didn’t work, until I put the 1 in front of my test number… so, as I said, in #2, it probably would have worked, just thrown a warning.
  4. I feel like an idiot. LOL

It certainly would have.

I tried the code recommended above by avayax. I get no error messages, but the email never arrived either. Anyone have any idea why?

My logs say this:

full-20200203:[2020-02-02 22:04:40] VERBOSE[30168][C-00000000] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] ExecIf(“SIP/####-00000000”, “0?System(echo “Ext #### - Location just placed a 911 emergency call on Sun Feb 2 22:04:40 2020” | mailx -s “911 Alert from ext #### - location” [email protected])”) in new stack

It didn’t return true/match otherwise it would be a 1 instead of a 0.

Okay, well that makes no sense. I changed the match to 811 and then dialed 811. I assumed that since it was in the log, it came back true.

I’ll fiddle with it some more. Thanks!

So add something that proves OUTNUM is set and what it is set to.

I figured it out. I map 811 to a ten-digit number. Outnum returns the ten-digit number. Duh…

Anyone know what the variable is for dialed number, rather than outnum?? (or do I just replace “s” with that?

Thank you. :slight_smile:

Macro() only uses the s extension for it. You would have to pass the dialed number into the marco as an argument and use that.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Standard+Channel+Variables

CALLERID(dnid) function

Thank you!

Because most providers will only allow e911 activation if you host the DID with them, and because FreePBX only supports one emergency DID per extension, I have my emergency route send 911 calls to my e911 enabled provider, but if that fails, it will failover to a backup trunk that will route calls to the PSAPs ten-digit number. The macro posted above will not send notifications in such cases, because the ${OUTNUM} will be the ten digit number and NOT 911. This code should catch that situation:

[macro-dialout-trunk-predial-hook]
exten => s,1,ExecIf($["${CALLERID(dnid)}"="911"]?System(echo "Ext ${AMPUSER} - ${AMPUSERCIDNAME} just placed a ${CALLERID(dnid)} emergency call on $TRFTIME(%C%m%d%y%H%M)}" | mailx -r "[email protected]" -s "${CALLERID(dnid)} Alert from ext ${AMPUSER} - ${AMPUSERCIDNAME}" [email protected]))
exten => s,n,MacroExit()