Summary:ASTERISK-12744: Cannot send more than one variable to a python script
Reporter:Great_anta_Baka (tjma2001)Labels:
Date Opened:2008-09-17 07:09:51Date Closed:2011-06-07 14:07:50
Versions:Frequency of
Description:I run my python script using the following command

exten = s,3,System(/usr/share/asterisk/agi-bin/something.py  "'${CDR(clid)) ${CDR(lastapp)}'")

and I get this error.

-- Executing [s@voicemenu-custom-1:3] System("SIP/6000-b6401e18", "/usr/share/asterisk/agi-bin/smsgateway.py  " Answer"") in new stack
Traceback (most recent call last):
 File "/usr/share/asterisk/agi-bin/smsgateway.py", line 19, in ?
   lastapp = sys.argv[2]
IndexError: list index out of range

The script works fine on the command line if is use two input variables. It also works in asterisk if i write it this way:

exten = s,3,System(/usr/share/asterisk/agi-bin/something.py  "'${CDR(clid)}'" "'${CDR(lastapp)}'")
Comments:By: Leif Madsen (lmadsen) 2008-09-17 07:20:30

I can't quite tell if this is python returning information due to it not getting the values correctly, or if this is an Asterisk response message. My guess is this is probably coming from python, but I had asked the bug reporter to file this just to make sure. So if you close this as not a bug, please don't give negative karma :)

By: Tilghman Lesher (tilghman) 2008-09-17 08:51:39

This is a python message, and I can tell immediately WHY.  The problem is that the reporter quoted the argument, so both variables come into python as a single argument.  Hence, there is no second argument to get.