Cursed Dynamic Route

I have a dynamic route that tells me the oldest call waiting, in seconds, from a specific queue. I am using a shell command.

${SHELL(asterisk -x "queue show 7500" | grep -nm1 "wait" | sed 's/..........$//' | tail -c 6 | awk -F: '{ print ($1 * 60) + $2 }')}

I need to evaluate if the wait time is more than 180 seconds. If true one route, otherwise the default route. I thought I could use:

$[${SHELL(asterisk -x "queue show 7500" | grep -nm1 "wait" | sed 's/..........$//' | tail -c 6 | awk -F: '{ print ($1 * 60) + $2 }')}>180]

The log shows:
dynroute=$

Any idea what I am doing wrong?

Or another solution to my problem, does anyone know how to pipe in a boolean at the end of my shell so I get back a 1 or 0 (true or false)?

Hi @comtech

Stray memory, when you’re doing complex expressions like these, particularly if you’re using square brackets, you need to disable the ‘enable substitutions’ in the dynroute.

I tested your expression and it’s working for me:

Up unitl the 3 min mark:

[[2024-06-11 10:21:56] VERBOSE[29594][C-00000040] pbx.c: Executing [s@dynroute-2:2] Set("PJSIP/7010-00000089", "dynroute=0") in new stack

and after the 3 min mark

[2024-06-11 10:22:29] VERBOSE[30357][C-00000041] pbx.c: Executing [s@dynroute-2:2] Set("PJSIP/7010-0000008c", "dynroute=1") in new stack
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.