I'm using phpagi $agi->get_data to read digit from user.
In some telephones, user didn't hit any key, but audio playback immediately stops and get result of "D" !!
I searched a lot about it, and looks like $agi-get_dat receives DTMF data that contains 0-9*#ABCD.
1st question is, why my users get "D" without hitting any key!
2nd question is, how can i ignore these characters to prevent interrupting my ivr.
phpagi getdata do this call
https://wiki.asterisk.org/wiki/display/AST/AGICommand_stream+file
so you can extend it by adding allowed digits param. PhpAGI lib is opensource and have source code.
Actualy you can just use stream_file call
stream_file (line 677)
Play the given audio file, allowing playback to be interrupted by a
DTMF digit. This command is similar to the GET DATA command but this
command returns after the first DTMF digit has been pressed while GET
DATA can accumulated any number of digits before returning.
return: see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no digit received,
otherwise a decimal value of the DTMF tone. Use chr() to convert to
ASCII.
link: http://www.voip-info.org/wiki-stream+file
example: Ping an IP address
array, stream_file (string $filename, [string $escape_digits = ''],
integer $offset)
string $filename: without extension, often in /var/lib/asterisk/sounds
string $escape_digits
integer $offset
you can check the logs by the following command :
asterisk -vvvvv
and you can check the value of the input for example in php code :
$val = $agi->get_data
exec("echo $val >> /tmp/output")
and then check this file : /tmp/output
Related
Hello Craftsmen Asterisk,
I have a problem I can not extract in the variable from SipHeader.
I followed with dump I'm getting:
Diversion: <sip:+4917645615686#public-vip.cisco.de>;reason=unconditional
Diversion: "Anonymous"sip<:Anonymous#47.23.21.9>;reason=unknow;privacy=full;counter=1
I set in dialplan:
same => n,Set(diversion=${SIP_HEADER(Diversion))
recived:
sip:+4917645615686#public-vip.cisco.de>;reason=unconditional
but I also need the second row!
Diversion: "Anonymous"sip<:Anonymous#47.23.21.9>;reason=unknow;privacy=full;counter=1
Can someone help me?
Maybe you should read help and use second param?
pro-sip*CLI> core show function SIP_HEADER
-= Info about function 'SIP_HEADER' =-
[Synopsis]
Gets the specified SIP header from an incoming INVITE message.
[Description]
Since there are several headers (such as Via) which can occur multiple times,
SIP_HEADER takes an optional second argument to specify which header with that
name to retrieve. Headers start at offset '1'.
Please observe that contents of the SDP (an attachment to the SIP request)
can't be accessed with this function.
[Syntax]
SIP_HEADER(name[,number])
[Arguments]
number
If not specified, defaults to '1'.
[See Also]
Not available
I made a call flow using php AGI in asterisk. For getting DTMF from caller, I have user fastpass_get_data() function of AGI. In this function caller can press any key. As and when caller press any key, playing prompt will be stoped.
Now I want that when caller press "1" at that time only that playing prompt will stop. So while prompt file is playing and user press any digit except "1", it will not affect playing file. But if user press "1" playing prompt file file should be stopped and call flow continue onwards.
Thanks !!!
Use streamfile command
stream file Usage: STREAM FILE <filename> <escape digits> [sample offset]
Send the given file, allowing playback to be interrupted by the given digits, if any.
Use double quotes for the digits if you wish none to be permitted.
If sample offset is provided then the audio will seek to sample offset before play starts.
Remember, the file extension must not be included in the filename.
Returns: failure: 200 result=-1 endpos=<sample offset> failure on open: 200 result=0 endpos=0 success: 200 result=0 endpos=<offset> digit pressed: 200 result=<digit> endpos=<offset>
http://www.voip-info.org/wiki/view/stream+file
I'm new to expect scripting, I want to write something like this:
set variable;
$variable = expect -exact "\/----Enter Password----\\"
while { != $variable } {
send -- {^[-}
}
I want to keep sending escape+hyphen character until I expect this prompt:
"\/----Enter Password----\\"
I have written the above code but it is not working. How do I do this?
You can make use of exp_continue to handle this situation. The command exp_continue allows expect itself to continue executing rather than returning as it normally would. This is useful for avoiding explicit loops or repeated expect statements. By default, exp_continue resets the timeout timer. The timer is not restarted, if exp_continue is called with the -continue_timer flag.
In expect, the default timeout is 10 seconds. i.e. the time till which expect will wait for the expected string to appear.
we used to give the expected string in expect as something like
expect "name"
which will wait for the string 'name' and proceed to next statement if timeout happened. To handle the timeout scenario, we are using the keyword timeout in expect itself.
expect {
"name" { # Some code here }
timeout { # timeout_hanlder_code_here }
}
You can change timeout value by using set command as shown below.
set timeout 60; # Timeout will happen after 60 seconds.
So, combining all together in one shot,
expect {
# If the phrase 'Enter Password' seen, then it will send the password
"Enter Password" {send "yourpassword\r"}
# If 'timeout' happened, then it will send some keys &
# 'expect' will be looped again.
timeout {send -- {^[-}; exp_continue}
}
Note : I am seeing a problem in your code. You have mentioned that you have to send escape + hyphen key together. But, you are sending only literal square bracket ([) and hyphen (-) symbol. If it is working then fine and you don't need to read this 'Note' section.Skip it. Else, proceed to read below.
You should send the actual Escape character to the program. It can be done as
send -- \033-; # Sending Escape + hyphen together
What is this \033 ? It is the octal code for Escape key. Then along with that we are just combining the hyphen with it's symbol as - which results in \033-. So our final code will be,
expect {
# If the phrase 'Enter Password' seen, then it will send the password
"Enter Password" {send "yourpassword\r"}
# If 'timeout' happened, then it will send some keys &
# 'expect' will be looped again.
timeout {send -- \033-; exp_continue}
}
Reference : Tcl's wiki & ASCII Char Table
I am observing one command in my TCL code (interpreter) . the command name is "interpreter" .
I searched on the google for this command , but I did not get much information .
Can anyone explain about this command ?
Thanks in advance .
Looks like I'm a year late, but maybe you're using Expect, a tcl plugin?
If you follow the link above search for interpreter " with ctrl+f you will find the following (bizarrely formatted) description:
causes the user to be interactively prompted for Expect and Tcl commands. The result of each command is printed.
Actions such as break and continue cause control structures (i.e., for, proc) to behave in the usual way. However return causes interpreter to return to its caller, while inter_return causes interpreter to cause a return in its caller. For example, if "proc foo" called interpreter which then executed the action inter_return, proc foo would return. Any other command causes interpreter to continue prompting for new commands.
By default, the prompt contains two integers.
The first integer describes the depth of the evaluation stack (i.e., how many times Tcl_Eval has been called). The second integer is the Tcl history identifier. The prompt can be set by defining a procedure called "prompt1" whose return value becomes the next prompt. If a statement has open quotes, parens, braces, or brackets, a secondary prompt (by default "+> ") is issued upon newline. The secondary prompt may be set by defining a procedure called "prompt2".
tl;dr: It pauses your script and allows you to execute tcl commands
I am sending a file from UNIX to MAINFRAME server via connect direct. I am able to upload the file successfully.At the destination host, when the file is received it is not readable and not in the same format as I sent from the UNIX server.
Below is the transmission job
Direct> Enter a ';' at the end of a command to submit it. Type 'quit;' to exit CLI.
submit maxdelay=unlimited TINIRS process snode=b1ap005
TRANSMIT copy from (file=myFile.txt
pnode
sysopts=":datatype=text"
)
ckpt=1k
to (file=myFile.txt(+1)
snode
DCB=(DSORG=PS,RECFM=VB,LRECL=1500)
disp=(new)
)
pend ;
Please let me know the DCB values needs to be updated. The file I am sending has 3 records of variable length and the maximum length of record is 1500.
Actually, that looks almost right. But if your maximum record length is 1500 characters (exclusive of the NL at the end of the line), your LRECL should be at least 1504. But don't skimp on the maximum - there's no cost or penalty to larger values (up to 32767). And NealB's correct - if this is a text file, you may need to specify a character-set translation - but I don't know how to do that in CONNECT:Direct.
C:D automatically converts ascii to EBCDIC when DATATYPE=TEXT is used. To be positive, you may want to use ":datatype=text:xlate=yes:".