Help with function CUT


How to display the 2nd and 3rd field?
If I have:

exten => s,1,Set(myVar="one-two-three")
exten => s,2,Set(cutVar=${CUT(myVar,-,2)})

It works. But in the example for comma separated value when put 2 instead of 1 it’s not working.

It’s some kind of bug of Asterisk 1.4. In 1.6 it’s fixed.

And still… do anyone know how to do this in 1.4?
If I escape the commas in myVar it’s working, but I can’t touch myVar.


This might be helpful?

I am using 1.4 to open doors based on the group they belong to.
You can see I only want the first three digits of the account code at priority 5 and 6.

exten => 67,1,Answer()
exten => 67,2,Wait(1)
exten => 67,3,Authenticate(/etc/asterisk/pwd_file,am,4)
exten => 67,4,NoOp(${CDR(accountcode)})
exten => 67,5,GotoIf($[${CDR(accountcode):0:3} = opp ]?7:6) ;Open opp doors
exten => 67,6,GotoIf($[${CDR(accountcode):0:3} = all ]?11:14) ;Open all doors
;Relay 1 open opperations doors
exten => 67,7,System(/usr/ar-2/ar-2 /dev/ttyS0 4 5)
exten => 67,8,NoOP(${SYSTEMSTATUS})
exten => 67,9,Wait(1)
exten => 67,10,Hangup()
;Relay 2 open all doors
exten => 67,11,System(/usr/ar-2/ar-2 /dev/ttyS0 6 5)
exten => 67,12,NoOP(${SYSTEMSTATUS})
exten => 67,13,Wait(1)
exten => 67,14,Hangup()


This is different. I do not know the string length and how many values MyVar have. There’s a function LEN to check the length, but I can’t split the string after the comma.