dslreports logo
 
    All Forums Hot Topics Gallery
spc
uniqs
47

Trev
AcroVoice & DryVoIP Official Rep
Premium Member
join:2009-06-29
Victoria, BC

Trev

Premium Member

Re: [Asterisk] hangup a channel from bash - odd behavior

In that case perhaps this would work for you:

- when a call to the extensions that may need hanging up come in, set a global variable with that extension number to the channel name
- create an extension that's sole purpose is to Hangup
- use the ChannelRedirect application to redirect that channel to the Hangup extension
SCADAGeo
Premium Member
join:2012-11-08
N California

SCADAGeo

Premium Member

said by Trev:

In that case perhaps this would work for you:

- when a call to the extensions that may need hanging up come in, set a global variable with that extension number to the channel name
- create an extension that's sole purpose is to Hangup
- use the ChannelRedirect application to redirect that channel to the Hangup extension

Nice way to work around the problem.

Debian 6 has a newer version of bash, so I wondered if it was an expansion quirk in the new version.

I downloaded v4.2.0, compiled, called it normally and with --posix.

Both methods worked... not sure where to go from here...

Just out of curiosity, are you running Debian 6.0.6?

What do the following show?

whereis asterisk

asterisk -rx "core show version"

grep ^`whoami` /etc/passwd

echo $SHELL

/bin/bash --version
dangmoo
join:2012-02-09

1 edit

dangmoo to Trev

Member

to Trev
said by Trev:

In that case perhaps this would work for you:

- when a call to the extensions that may need hanging up come in, set a global variable with that extension number to the channel name
- create an extension that's sole purpose is to Hangup
- use the ChannelRedirect application to redirect that channel to the Hangup extension

Thank you Trev, based on your tip the problem has been solved. Bravo.

A priority was added to the target extension like this:
same => n,Set(GLOBAL(CHANTOKILL)=${CHANNEL})
 

and by adding this line to any other extension, call is hangup:
same => n,Set(result=${SHELL(asterisk -rx "channel request hangup ${CHANTOKILL}")})
same => n,NoOp(result is: ${result})
 

However, I'm still curious why the original code didn't work for me. This will remain an open question until someone solves this mystery
SCADAGeo
Premium Member
join:2012-11-08
N California

SCADAGeo

Premium Member

said by dangmoo:

said by Trev:

In that case perhaps this would work for you:

Thank you Trev, based on your tip the problem has been solved. Bravo.

Cool!
said by dangmoo:

It worked normally when using the command without variables. Problem occurred only when a variable was involved

I understood.
said by dangmoo:

However, I'm still curious why the original code didn't work for me. This will remain an open question until someone solves this mystery

I am curious, too, that's why I asked for the information.

I want to recreate your environment, but the full distro of Debian 6.0.6 contains 7 DVD's... it would be a waste of bandwidth and time to download a version that is different than the one you are using.
dangmoo
join:2012-02-09

1 edit

dangmoo

Member

Sure SCADAGeo, sorry for delay.
I'm on a Debian Squeeze 32bit VPS, connected via SSH. Yes, it's the version 6.0.6 .
Hope the following info helps:
root@codeplace:~# cat /etc/debian_version
6.0.6
root@codeplace:~# whereis asterisk
asterisk: /usr/sbin/asterisk /etc/asterisk /usr/lib/asterisk /usr/include/asterisk /usr/include/asterisk.h /usr/share/man/man8/asterisk.8
root@codeplace:~# asterisk -rx "core show version"
Asterisk 1.8.3.3 built by root @ codeplace on a i686 running Linux on 2012-12-09 21:30:06 UTC
root@codeplace:~# grep ^`whoami` /etc/passwd
root:x:0:0:root:/root:/bin/bash
root@codeplace:~# echo $SHELL
/bin/bash
root@codeplace:~# /bin/bash --version
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>