String search/comparison with gotoif

Hello, Good morning,
Here I am sharing code and cli log

exten => 727274,1,Answer()
same => n,Set(tempvalueeee=one)
same => n,Set(result=none)
same => n,ExecIf($[“${tempvalueeee}” = thirtyone]?Set(result=ClasssS31))
same => n,ExecIf($[“${tempvalueeee}” = twentyone]?Set(result=ClasssS21))
same => n,ExecIf($[“${tempvalueeee}” = elevone]?Set(result=ClasssS11))
same => n,ExecIf($[“${tempvalueeee}” = one]?Set(result=ClasssS1))

same => n,ExecIf($[“${result}” = none]?Hangup())

same => n,System(echo -e “${CALLER_ID},–,${result},${tempvalueeee}” >> /root/tempfiles/test2/logrecord5.log)

same => n,Hangup()

< Executing [727274@default:1] Answer(“SIP/8081-000000cf”, “”) in new stack
– Executing [727274@default:2] Set(“SIP/8081-000000cf”, “tempvalueeee=one”) in new stack
– Executing [727274@default:3] Set(“SIP/8081-000000cf”, “result=none”) in new stack
– Executing [727274@default:4] ExecIf(“SIP/8081-000000cf”, “0?Set(result=ClasssS31)”) in new stack
– Executing [727274@default:5] ExecIf(“SIP/8081-000000cf”, “0?Set(result=ClasssS21)”) in new stack
– Executing [727274@default:6] ExecIf(“SIP/8081-000000cf”, “0?Set(result=ClasssS11)”) in new stack
– Executing [727274@default:7] ExecIf(“SIP/8081-000000cf”, “0?Set(result=ClasssS1)”) in new stack
– Executing [727274@default:8] ExecIf(“SIP/8081-000000cf”, “0?Hangup()”) in new stack
– Executing [727274@default:9] System(“SIP/8081-000000cf”, “echo -e “,–,none,one” >> /root/tempfiles/test2/logrecord5.log”) in new stack
– Executing [727274@default:10] Hangup(“SIP/8081-000000cf”, “”) in new stack
== Spawn extension (default, 727274, 10) exited non-zero on ‘SIP/8081-000000cf’
/>

output of logrecord5.log
“,–,none,one”

Thanks @Pooh @TheMark @sedwards
Following is working fine if I eliminate " " from variable value.

exten => 727274,1,Answer()
same => n,Set(tempvalueeee=one)
same => n,Set(result=none)
same => n,ExecIf($[“${tempvalueeee}” = “twentyone”]?Set(result=ClasssS31))
same => n,ExecIf($[“${tempvalueeee}” = “one”]?Set(result=ClasssS21))
same => n,ExecIf($[“${tempvalueeee}” = “elevone”]?Set(result=ClasssS11))
same => n,ExecIf($[“${tempvalueeee}” = “thirtyone”]?Set(result=ClasssS1))
same => n,ExecIf($[“${result}” = none]?Hangup())
same => n,System(echo -e “${CALLER_ID},–,${result},${tempvalueeee}” >> /root/tempfiles/test2/logrecord5.log)
same => n,Hangup()

Good. I’m glad we’ve been able to help.

I do recommend leaving the " around “none” in the final comparison:

same => n,ExecIf($[“${result}” = “none”]?Hangup())

Antony.

@helpinghandindia with 40+ variations of GotoIf i recomend using my first excample as it willl execute less code
as it will use pattern match to find the correct line

Thanks, I appreciate your support.

As per my requirements , I am going to deploy like this.
Do you have any suggestion or it is okay to use ahead.

exten => s,n,ExecIf($[“${tempvalueeee}” = “one”]?Goto(ClassS1))
exten => s,n,ExecIf($[“${tempvalu1eee}” = “वन”]?Goto(ClassS1))
exten => s,n,ExecIf($[“${tempvalueeee}” = “two”]?Goto(ClassS2))
exten => s,n,ExecIf($[“${tempvalu1eee}” = “तो”]?Goto(ClassS2))
exten => s,n,ExecIf($[“${tempvalueeee}” = “three”]?Goto(ClassS3))
exten => s,n,ExecIf($[“${tempvalu1eee}” = “थ्री”]?Goto(ClassS3))
exten => s,n,ExecIf($[“${tempvalueeee}” = “four”]?Goto(ClassS4))
exten => s,n,ExecIf($[“${tempvalu1eee}” = “फोर”]?Goto(ClassS4))

I think ‘application specific’ log files are evil. I’d funnel it to syslog.

Every time I see shell-spawning commands like System(), I get nervous. It would be really good if there was a command to spawn an external command directly, without going through a shell, and be able to feed it an array of argument strings that will be taken literally, without having to worry about some shell getting in the way and interpreting funny characters in unexpected ways.

yes please use sub context like in my first post as it will only excute 2 linse no mater how many variation of ${tempvalueeee} you have, where with your code you will execute on avarage 40+/2 lines

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