[Freeswitch-users] Set command is not working with the variable value in freeswitch
Iskren Hadzhinedev
iskren.hadzhinedev at ikiji.com
Mon May 12 12:23:03 MSD 2014
Hello Nikhitha,
I have a similar scenario and I'm using mod_python. It's a bit more complicated, but it is very fast and reliable. If you have that module, you can use the following as a solution:
1) Create a file getplayfile.py with the following contents:
*-- Copy below --*
import freeswitch
def handler(session, args):
pass
def fsapi(session, stream, env, args):
with open("/tmp/%s" % args, "r") as f:
stream.write(f.readline().rstrip('\n'))
*-- End copy --*
2) Place that file somewhere in the python path, for centos 6.5 that's /usr/lib/python2.6/site-packages, 64bit systems use /usr/lib64/python2.6/site-packages
3) Modify your dialplan:
<action application="set" data="RESULT=${python(getplayfile ${uuid})}"/>
/P.S. I'm pretty sure the same can be done with mod_lua or mod_perl, but I'm not using them so I can't provide a solution./
Kind regards,
--
Iskren Hadzhinedev
Ian
As you told here the performances are unacceptable , I dont want the live caller to experience such issues.So how to overcome this issue and can you tell me what are the other approaches that solve the problem by increasing and not by increasing the complexity.
On Fri, May 9, 2014 at 5:16 PM, Ian McMaster <ian.mcmaster at gmail.com[1]> wrote:
Nikhitha,
I doubt that the poor response time is caused by the script itself. For example, from the shell, time your script using "time <script.sh>". You will probably get a time around 10ms. This should not be a concern, and would be difficult to improve.
The problem most likely is the choice of using 'system'. A system() call is an expensive choice in terms of performance. There is a lot of overhead going on in the operating system in the process.
You can perform a few quick tests to see where your issue lies: Use the freeswitch logs to see what the total time of the system call is, and then use the "time <script.sh>" to see what the time is from the shell. I think you will find that the issue is "system" and not the script itself.
Is the performance unacceptable because a live caller experiences an unacceptable pause? If so, can you run the system command prior to the start of the script? There are other approaches to solve your problem, but they increase in complexity.
Ian.
On Fri, May 9, 2014 at 3:24 AM, Nikhitha T <nikhitha.voxta at gmail.com[2]> wrote:
Ian
Thank you for the reply that worked for me and I have one more doubt.
While executing a shell script from the dial plan it is consuming much time to execute that script.How can i overcome this problem in reducing execution time of shell script when used in dial plan.
On Thu, May 8, 2014 at 7:35 PM, Ian McMaster <ian.mcmaster at gmail.com[1]> wrote:
Nikhitha,
You are using 'sed' to print the first line (head -1), which will include a line return.
This will work:
Create a shell script "getplayfile.sh" and in your dialplan use:
* data="RESULT=${system getplayfile.sh}"*
The shell script can use tr to strip out the end of line as follows:
sed -n 1p /nfs/th/play/${uuid} | tr "\n" "\0"
On Thu, May 8, 2014 at 6:55 AM, Nikhitha T <nikhitha.voxta at gmail.com[2]> wrote:
In freeswitch as I am setting the variable like this
*<action application="set" data="RESULT=${system sed -n 1p /nfs/th/play/${uuid}}" inline="true"/>*
*1002 at 192.168.0.106[3] SET [RESULT]=[/usr/local/freeswitch/sounds/en/us/callie/directory/8000/dir-for_prev.wav
]*
*2014-05-08 13:34:56.679046 [ERR] switch_core_file.c:150 Invalid file format [wav
] for [/usr/local/freeswitch/sounds/en/us/callie/directory/8000/dir-for_prev.wav
]!
*
Can anyone help me in solving this issue.Thanks in advance
_________________________________________________________________________Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org[4]
http://www.freeswitchsolutions.com[5]
[6]
http://www.freeswitch.org[7]
http://wiki.freeswitch.org[8]
http://www.cluecon.com[9]
FreeSWITCH-users at lists.freeswitch.org[10]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users[11]
http://lists.freeswitch.org/mailman/options/freeswitch-users[12]
http://www.freeswitch.org[7]
consulting at freeswitch.org[4]
http://www.freeswitchsolutions.com[5]
[6]
http://www.freeswitch.org[7]
http://wiki.freeswitch.org[8]
http://www.cluecon.com[9]
FreeSWITCH-users at lists.freeswitch.org[10]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users[11]
http://lists.freeswitch.org/mailman/options/freeswitch-users[12]
http://www.freeswitch.org[7]
consulting at freeswitch.org[4]
http://www.freeswitchsolutions.com[5]
[6]
http://www.freeswitch.org[7]
http://wiki.freeswitch.org[8]
http://www.cluecon.com[9]
FreeSWITCH-users at lists.freeswitch.org[10]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users[11]
http://lists.freeswitch.org/mailman/options/freeswitch-users[12]
http://www.freeswitch.org[7]
consulting at freeswitch.org[4]
http://www.freeswitchsolutions.com[5]
[6]
http://www.freeswitch.org[7]
http://wiki.freeswitch.org[8]
http://www.cluecon.com[9]
FreeSWITCH-users at lists.freeswitch.org[10]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users[11]
http://lists.freeswitch.org/mailman/options/freeswitch-users[12]
http://www.freeswitch.org[7]
--------
[1] mailto:ian.mcmaster at gmail.com
[2] mailto:nikhitha.voxta at gmail.com
[3] mailto:1002 at 192.168.0.106
[4] mailto:consulting at freeswitch.org
[5] http://www.freeswitchsolutions.com
[6]
[7] http://www.freeswitch.org
[8] http://wiki.freeswitch.org
[9] http://www.cluecon.com
[10] mailto:FreeSWITCH-users at lists.freeswitch.org
[11] http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
[12] http://lists.freeswitch.org/mailman/options/freeswitch-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140512/0d4d1457/attachment-0001.html
Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users
mailing list