Agi get full variable

Hi Guys,
I need to check the sate of exten from AGI, I am using “GET FULL VARIABLE” AGI command, but I am not able to make it working right:

in a simple bash script I have:
#!/bin/bash
echo “GET FULL VARIABLE DEVICE_STATE(SIP/109)”
read RESPONSE
exit 0

I get the string DEVICE_STATE(SIP/109) and not the value. I tried ${DEVICE_STATE(SIP/109)} and in this case I get back nothing

Any suggestions ? What is the mistake ?

Thanks in advance

Unfortunately this is all a bit vague and feels incomplete. Based on what you provided it won’t work and I don’t see enough information to know what you actually want or to point in the right direction
What’s the goal?
Can you walk me through what you’re hoping to do once you know the device state? Are you making call routing decisions, displaying it somewhere, etc.?
Can you give me more details?
What Asterisk version are you on?
Is SIP/109 a specific device you have, or just a placeholder?
How does this script fit into your dialplan? Can you show the dialplan?

This issue is a bash one, not an Asterisk one, although the first error may be the result of not marking up correctly for the forum.

david@dhcppc4:~$ echo “GET FULL VARIABLE DEVICE_STATE(SIP/109)”
bash: syntax error near unexpected token `('
david@dhcppc4:~$ echo "GET FULL VARIABLE DEVICE_STATE(SIP/109)"
GET FULL VARIABLE DEVICE_STATE(SIP/109)
david@dhcppc4:~$ echo "GET FULL VARIABLE ${DEVICE_STATE(SIP/109)}"
bash: GET FULL VARIABLE ${DEVICE_STATE(SIP/109)}: bad substitution
david@dhcppc4:~$ echo 'GET FULL VARIABLE ${DEVICE_STATE(SIP/109)}'
GET FULL VARIABLE ${DEVICE_STATE(SIP/109)}
david@dhcppc4:~$

Either use single quotes or escape the brackets.

echo 'GET FULL VARIABLE DEVICE_STATE(SIP/109)'

echo “GET FULL VARIABLE DEVICE_STATE\(SIP/109\)”

(You can only use S{VARIABLES} within double quotes.)

The double quotes need to be the core ASCII ones, not the slanted ones that appeared in the forum. That is why the parentheses were rejected, but they would cause other errors, so I suspect they actually got introduced whilst submitting to the forum…

Although the synopsis documentation is totally confusing, there is a summary table that makes it clear that GET FULL VARIABLE is really GET EXPRESSION VALUE, so I think the $ are important, for which you need extensive backquoting, or single quotes, in the shell.

Thanks !
using echo ‘GET FULL VARIABLE ${DEVICE_STATE(SIP/109)}’ it works !

Great !

No, ${DEVICE_STATE(SIP/109)} will NOT be resolved within single quotes in the bash shell . . .

Not resolving within the shell is the intended outcome!