dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
share rss forum feed

dangmoo

join:2012-02-09
reply to dangmoo

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

OK.
I've just solved the problem,
In short, what happened was that 7 hidden characters were appended just before the beginning of the $CHANNEL value.
I checked the string-lenght of $CHANNEL and to my surprise it showed 24, while only 17 were visible:

root@codeplace:~# asterisk -rx "core show channels concise"
SIP/1001-00000175!default!124!7!Ring!Playback!holdmusic,noanswer!1001!!!3!8!(None)!1355439097.373
root@codeplace:~# echo $CHANNEL
SIP/1001-00000175
root@codeplace:~# echo $CHANNEL | awk '{print length}'
24
 

If you wondered what were these hidden characters here it is (time info?):
root@codeplace:~# echo ${CHANNEL:0}
SIP/1001-00000175
root@codeplace:~# echo ${CHANNEL:1}
[0;37mSIP/1001-00000175
 

Anyway, for hanging it up from bash shell, $CHANNEL variable must started from its position number 7:

root@codeplace:~# CHANNEL=`asterisk -rx "core show channels concise" | grep 124 | cut -f1 -d'!'`; asterisk -rx "channel request hangup ${CHANNEL:7}"
Requested Hangup on channel 'SIP/1001-00000175'
 

Hope this help someone :-)


Trev
IP Telephony Addict
Premium
join:2009-06-29
Victoria, BC
kudos:6

Those nondisplaying characters are ANSI control codes. They give you the different colours on the shell.

From a security perspective, I would stay far far far away from a shell script like this that that runs as root. This is exactly the kind of thing attackers take advantage of to compromise systems.
--
Wondering what I do? Find out at »www.digitalcon.ca
Get your Obihai ATA in Canada.