is it possible to make a gosubif not only with comparing a variable with a number?
in an ivr, i save dtmf-inputs in a global variable PIN:
exten=>s,1,Read(GLOBAL(PIN),soundfile,8,2,20)
in an other ivr i want compare the variable PIN with the caller input PININPUT, and if it is the same, gosub pinok
exten=>s,1,Read(GLOBAL(PININPUT),soundfile,8,2,20)
same=>n,GosubIf($[“${PIN}” = “${PININPUT}”]?pinok,s,1)
but no matter if the caller input is (correct pin or wrong pin), it goes to pinok.
if i replace “${PIN}” with a number (1234), it works fine.
if the caller type in the correct PININPUT 1234 it goes to pinok, if the caller type in the wrong PININPUT, it jumps to the next line.
same=>n,GosubIf($[“1234” = “${PININPUT}”]?:pinnotok,s,1)
what do i wrong?
or can someone help me to do this?
Blockquote
Executing [s@eingabe1:1] Read(“PJSIP/mytrunk95-00000068”, “GLOBAL(PINEINGABE),pinabfrage,8,2,20”) in new stack
– Accepting a maximum of 8 digits.
– <PJSIP/mytrunk95-00000068> Playing ‘pinabfrage.g722’ (language ‘de’)
0x14a95c049bd0 – Strict RTP learning complete - Locking on source address 212.117.203.60:41748
== Setting global variable ‘PINEINGABE’ to ‘444’
– User entered ‘444’
– Executing [s@eingabe1:2] SayDigits(“PJSIP/mytrunk95-00000068”, ““123"”) in new stack
[Dec 4 22:37:45] WARNING[1656][C-00000069]: file.c:824 ast_openstream_full: File does not exist in any format
[Dec 4 22:37:45] WARNING[1656][C-00000069]: file.c:1303 ast_streamfile: Unable to open (format (g722)): No such file or directory
– <PJSIP/mytrunk95-00000068> Playing ‘digits/1.alaw’ (language ‘de’)
– <PJSIP/mytrunk95-00000068> Playing ‘digits/2.alaw’ (language ‘de’)
– <PJSIP/mytrunk95-00000068> Playing ‘digits/3.alaw’ (language ‘de’)
– Executing [s@eingabe1:3] SayDigits(“PJSIP/mytrunk95-00000068”, “444”) in new stack
– <PJSIP/mytrunk95-00000068> Playing ‘digits/4.alaw’ (language ‘de’)
– <PJSIP/mytrunk95-00000068> Playing ‘digits/4.alaw’ (language ‘de’)
– <PJSIP/mytrunk95-00000068> Playing ‘digits/4.alaw’ (language ‘de’)
[Dec 4 22:37:49] WARNING[1656][C-00000069]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘’, expecting $end; Input:
““123"” : “444”
^
[Dec 4 22:37:49] WARNING[1656][C-00000069]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to Home - Asterisk Documentation
– Executing [s@eingabe1:4] GosubIf(“PJSIP/mytrunk95-00000068”, “””?pinok,s,1”) in new stack
– Executing [s@pinok:1] Playback(“PJSIP/mytrunk95-00000068”, “eintreten”) in new stack
so you can see, it is 123 and 444 but execute pinok
Your original example used =, but the log and your last posting have : which is a regular expression operator, not an equality one.
I note that you have a syntax error:
You haven’t reproduced the log correctly, as all the quotes should be simple double quote ("). That means it isn’t possible to tell whether there is a real fancy quote in the original which is messing things up.
sorry my english isn’t the best, can you please explain more detailed what you want know?
and after work i will make a new log with correct syntax, i think it will be better.
but problem is following:
x digits dtmf in variable 1
x digits dtmf in variable 2
gosubif if both variables is the same.
my question is, is it possible to compare 2 variables?
as example if i compare variable with callerid it works correct.
only 2 variables always answer with true, alsi if they are different
Yes, although strictly speaking, the variables are replaced by their values before the expression is parsed, so you only ever compare the values. That is why the syntax error message quotes the values, not the variable names.
sorry this was also a mistake by testing too many variants.
i defined the global variable
PIN = “123”
That’s why it is wrong.
but in the normal process this will be overwritten by dtmf-inputs, as same as the PININPUT will be.
and for comparing i use ${} for both PIN and PININPUT, so i think i can be sure to compare the saved digits in both variables.
or do i understand ${} wrong?
I’m pretty sure that there is something wrong with your use of quotes, and in particular, I think one string may be quoted twice, but what you have provided here has invalid quote characters, and I am not sure if that has happened when pasting into the forum, or in the actual files provided to Asterisk.
Your logs contain U+201C and U+201D characters, but all the quotes should be U+0022. (Left Double Quotation Mark, Right Double Quotation Mark, and Quotation Mark)
This is typically the results of using word processing type software.
You are right, next step will be integrating the DB functions.
But with only one PIN it is ok with the variable, or is it a security risk to use global variables?
And you are half right, i develop an access system without the needing of an input terminal at the door.
The guest only need to know the number to call and the pin.
The admin can change the pin.
For the door i need only internet and a relaisbox.
Asterisk/VPN in the cloud, or local on a raspberry or something like this.
I like AstLinux
Minimal security risk in that scenario. Users are not exposed to the contents of your dial plan. Their phone can’t start telling them what global variables are set to unless you configure it that way eg. using Playback() application, allowing some other API access, etc.
The issue is that setting global variables on-the-fly will not persist between restarts (not a new feature, either.)
Try this on the Asterisk CLI:
*CLI> dialplan show globals
-- 0 variable(s)
*CLI> dialplan set global SOMEPIN 1234
-- Global variable 'SOMEPIN' set to '1234'
== Setting global variable 'SOMEPIN' to '1234'
*CLI> dialplan show globals
SOMEPIN=1234
-- 1 variable(s)
*CLI> core restart now
Then reconnect to Asterisk CLI aaaaaaaaaaaand it’s gone!