[Freeswitch-users] return to shell only when call from originate is complete?

Michael Jerris mike at jerris.com
Mon May 22 04:25:03 UTC 2017


fs_cli IS the esl route.  Cleaner to just use esl and call the api command
you want directly instead of hacky stuff like this.


On Sun, May 21, 2017 at 11:44 AM Bipin Patel <bipin at xbipin.com> wrote:

> hi,
>
> im trying to avoid going the esl route, for now i solved this by calling a
> bash script from python which monitors the call once the UUID is passed to
> it so that holds the python command till call is over and then it proceeds
> further
>
>
> Regards,
> Bipin
>
>
> ------------------------------
> -------- Original Message --------
> Subject: Re: [Freeswitch-users] return to shell only when call from
> originate is complete?
> From: Tihomir Culjaga <tculjaga at gmail.com> <tculjaga at gmail.com>
> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> <freeswitch-users at lists.freeswitch.org>
> Date: 5/21/2017, 7:25:31 PM
>
> i still think you are better consume events with python...
> its easy and straightforward
>
>
> #!/usr/bin/env python
>
> import string
> import sys
>
> from ESL import *
>
> con = ESLconnection("127.0.0.1","8021","ClueCon")
> #are we connected?
> callDirection = "unknown"
>
>
> if con.connected:
>   print "we connected \n"
>   con.events("plain", "all");
>
>   while 1:
>   #my $e = $con->recvEventTimed(100);
>     e = con.recvEvent()
>
>     if e:
>       #print e.serialize()
>       en = e.getHeader("Event-Name")
>       print "Name =>" ,en
>
>       if en == "CHANNEL_OUTGOING":
>         callDirection = "OUT"
>         print "Direction =", callDirection
>
>       elif en == "CHANNEL_ORIGINATE":
>         print "Originate call - direction =", callDirection
>
>       elif en == "CHANNEL_CALLSTATE":
>         print "Call State =>", e.getHeader("Answer-State")
>
>       elif en == "CHANNEL_ANSWER":
>         print "Call START - direction =", callDirection
>
>       elif en == "CHANNEL_HANGUP":
>         print "Call END - direction =", callDirection
>
>       elif en == "CHANNEL_PARK":
>         callDirection = "IN"
>         print "Call PARK - direction =", callDirection
>
>
>
> you can work it out from here pretty everything you want.
>
>
> T.
>
> On 21 May 2017 at 14:32, Bipin Patel <bipin at xbipin.com> wrote:
>
>> hi,
>>
>> i converted the bash script to python as below:
>>
>> ret = subprocess.Popen('sudo fs_cli -x \"show channels\" | grep -c
>> \"'+UUID+'\"', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>> sout, serr = ret.communicate()
>> print sout
>>
>> the reason i use -c instead of -q is because fs_cli always returns a 0
>> exit code so it doesnt work through python when combined with grep so i
>> tried to exit loop when the counter is 0 meaning the call is completed, but
>> the above returns some weird numbers in sout, when the call is running it
>> shows 5 and when done shows 3 but same if i run directly through console it
>> shows accurately.
>>
>> any idea how to fix this?
>>
>>
>> Regards,
>> Bipin
>>
>>
>> ------------------------------
>> -------- Original Message --------
>> Subject: Re: [Freeswitch-users] return to shell only when call from
>> originate is complete?
>> From: William Simon <wsimon at stratusvideo.com> <wsimon at stratusvideo.com>
>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
>> <freeswitch-users at lists.freeswitch.org>
>> Date: 5/20/2017, 1:29:05 AM
>>
>> If you are using fs_cli then a simple shell script can monitor the call
>> and return when the call completes:
>>
>> #!/bin/bash
>>
>> RESULT=$( fs_cli -x "originate leg1 leg2" )
>>
>> if [[ $RESULT =~ "OK" ]]; then
>>         UUID=$( echo "$RESULT" | cut -f 2 -d ' ' )
>>         while fs_cli -x "show channels" | grep -q $UUID ;
>>         do
>>                 sleep 5;
>>         done
>>         echo "Call completed."
>> fi
>>
>>
>>
>>
>> On May 19, 2017, at 12:31 PM, Bipin Patel <bipin at xbipin.com> wrote:
>>
>> hi,
>>
>> any other way this can be done
>>
>>
>> Regards,
>> Bipin
>>
>>
>> ------------------------------
>> -------- Original Message --------
>> Subject: Re: [Freeswitch-users] return to shell only when call from
>> originate is complete?
>> From: Michael Jerris <mike at jerris.com> <mike at jerris.com>
>> To: Bipin Patel <bipin at xbipin.com> <bipin at xbipin.com>
>> Date: 5/19/2017, 7:48:22 PM
>>
>> No, thats not what originate does.
>>
>> On May 19, 2017, at 11:43 AM, Bipin Patel <bipin at xbipin.com> wrote:
>>
>> hi,
>>
>> does it happen right after answer?
>> is there any way to lock it so it returns only after failure or after
>> hangup? yes im using ignore_early_media
>>
>>
>> Regards,
>> Bipin
>>
>>
>> ------------------------------
>> -------- Original Message --------
>> Subject: Re: [Freeswitch-users] return to shell only when call from
>> originate is complete?
>> From: Michael Jerris <mike at jerris.com> <mike at jerris.com>
>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
>> <freeswitch-users at lists.freeswitch.org>
>> Date: 5/19/2017, 7:34:35 PM
>>
>> originate returns when we get call progress, or in the case of
>> ignore_early_media, on answer or failure.
>>
>> On May 19, 2017, at 10:36 AM, Bipin Patel <bipin at xbipin.com> wrote:
>>
>> hi,
>>
>> i was wondering if its possible to to release handle from an originate
>> command only once the call is completed, i mean i send a originate command
>> from shell using fs_cli but only return back to prompt once the call is
>> completed rather than as soon as a bridge is created or a UUID generated
>>
>>
>>
>>
>>
>>
>> “The information transmitted is intended only for the person or entity to
>> which it is addressed and may contain proprietary, business-confidential
>> and/or privileged material. If you are not the intended recipient of this
>> message you are hereby notified that any use, review, retransmission,
>> dissemination, distribution, reproduction or any action taken in reliance
>> upon this message is prohibited. If you received this in error, please
>> contact the sender and delete the material from any computer.”
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>>
>>
>> “The information transmitted is intended only for the person or entity to
>> which it is addressed and may contain proprietary, business-confidential
>> and/or privileged material. If you are not the intended recipient of this
>> message you are hereby notified that any use, review, retransmission,
>> dissemination, distribution, reproduction or any action taken in reliance
>> upon this message is prohibited. If you received this in error, please
>> contact the sender and delete the material from any computer.”
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:consulting at freeswitch.orghttp://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Siteshttp://www.freeswitch.orghttp://confluence.freeswitch.orghttp://www.cluecon.com
>>
>> FreeSWITCH-users mailing listFreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:consulting at freeswitch.orghttp://www.freeswitchsolutions.com
>
> Official FreeSWITCH Siteshttp://www.freeswitch.orghttp://confluence.freeswitch.orghttp://www.cluecon.com
>
> FreeSWITCH-users mailing listFreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170522/f8c766b1/attachment-0001.html>


More information about the FreeSWITCH-users mailing list