Re: [asterisk-users] Hangup extensions via CLI?
Ok isn't this replacing a western hack with a bridge hack? The init 0 and init 6 probably aren't going to work anyway since (1) asterisk has to be running as root and (2) the path in * is limited if even existent, so the init command would work unless you had a copy or symlink in the asterisk directory. -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Tzafrir Cohen Sent: Sunday, February 15, 2009 11:26 PM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] Hangup extensions via CLI? On Mon, Feb 16, 2009 at 12:15:08AM -0500, Alexander Lopez wrote: This will hang-up all channels even if multiples channels are open... Exten = _86,1,system(init 0) Use with Caution.? Only if Asterisk is running as root. Which is not recommended, anyway. And besides, I think you meant: Exten = _86,1,system(init 6) as we want to leave the extension available afterwards. -- Tzafrir Cohen icq#16849755 jabber:tzafrir.co...@xorcom.com +972-50-7952406 mailto:tzafrir.co...@xorcom.com http://www.xorcom.com iax:gu...@local.xorcom.com/tzafrir ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
On Tue, Feb 17, 2009 at 08:57:51AM -0600, Danny Nicholas wrote: Ok isn't this replacing a western hack with a bridge hack? The init 0 and init 6 probably aren't going to work anyway since (1) asterisk has to be running as root and I have already mentioned that this is a requirement. (2) the path in * is limited if even existent, so the init command would work unless you had a copy or symlink in the asterisk directory. # tr '\0' '\n' /proc/`cat /var/run/asterisk/asterisk.pid`/environ | grep ^PATH= PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin Init scripts tend to set the path explicitly. So those are just poor excuses for not using that fine hangup method. -- Tzafrir Cohen icq#16849755 jabber:tzafrir.co...@xorcom.com +972-50-7952406 mailto:tzafrir.co...@xorcom.com http://www.xorcom.com iax:gu...@local.xorcom.com/tzafrir ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
This will hang-up all channels even if multiples channels are open... Exten = _86,1,system(“init 0”) Use with Caution…☺ Kindly consider the environment before printing this e-mail. From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Lenz Emilitri Sent: Friday, February 13, 2009 3:52 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] Hangup extensions via CLI? This version will hang up the given extension even if it has multiple channels open: asterisk -rx show channels | perl -lane print \asterisk -rx \'soft hangup @F[0]\'\ if m.SIP/201. | bash perl is always your friend when needing some programming mischief :) l. 2009/2/12 Danny Nicholas da...@debsinc.com Here's an improved hack to this bit of trickery: Exten = _86,1,system('/usr/sbin/asterisk -rx soft hangup $(/usr/sbin/asterisk -rx 'core show channels' | grep SIP/${EXTEN(2)| awk '{ print $1 '} )) Where dialing 861234 would hangup extension 1234 If this needs refinement, will repost: -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Helius Ferreira Sent: Thursday, February 12, 2009 4:42 AM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] Hangup extensions via CLI? Asterisk 1.6 implements the hangup on the channel you just made the call and I used it with this command (apparently) asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000| awk '{ print $1 '} ) In my asterisk system: debian*CLI core show channels Channel Location State Application(Data) SIP/7000-09c63a30 (None) Up AppDial((Outgoing Line)) SIP/-09c59938 7...@internos:5 Up Dial(SIP/7000) 2 active channels 1 active call 6 calls processed debian*CLI debian:~# asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000|awk '{ print $1 '} ) SIP/7000-09c63a30 SIP/-09c59938 is not a known channel But, with the channel SIP/-09c59938 is OK. asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/| awk '{ print $1 '} ) Requested Hangup on channel 'SIP/-09c59938' I use asterisk 1.6.1 beta4 On Wed 11 Feb 2009 09:34:12 Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) It basically calls *, gets the list of channels, filters them out to get the channel name and hangs it up. OK, using AMI and a real programming language and hadling multiple lines would be better. Thanks l. 2009/2/9 Tim Nelson tnel...@rockbochs.com Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Loway - home of QueueMetrics - http://queuemetrics.com ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
On Mon, Feb 16, 2009 at 12:15:08AM -0500, Alexander Lopez wrote: This will hang-up all channels even if multiples channels are open... Exten = _86,1,system(“init 0”) Use with Caution…☺ Only if Asterisk is running as root. Which is not recommended, anyway. And besides, I think you meant: Exten = _86,1,system(“init 6”) as we want to leave the extension available afterwards. -- Tzafrir Cohen icq#16849755 jabber:tzafrir.co...@xorcom.com +972-50-7952406 mailto:tzafrir.co...@xorcom.com http://www.xorcom.com iax:gu...@local.xorcom.com/tzafrir ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
On Wed, 11 Feb 2009 12:34:12 +0100, Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) what if there're also channels sip/201, sip/2011, sip/2012, sip/2013 et al ? -- Regards, /\_/\ All dogs go to heaven. din...@alphaque.com(0 0) http://www.openmalaysiablog.com/ +==oOO--(_)--OOo==+ | for a in past present future; do| | for b in clients employers associates relatives neighbours pets; do | | echo The opinions here in no way reflect the opinions of my $a $b. | | done; done | +=+ ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
On Fri, Feb 13, 2009 at 06:08:45PM +0800, Dinesh Nair wrote: On Wed, 11 Feb 2009 12:34:12 +0100, Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) Useless use of grep: asterisk -rx soft hangup $(asterisk -rx 'show channels' | awk '/SIP\/201/ {print $1}' ) what if there're also channels sip/201, sip/2011, sip/2012, sip/2013 et al ? asterisk -rx soft hangup $(asterisk -rx 'show channels' | awk '/SIP\/201\/ {print $1}' ) -- Tzafrir Cohen icq#16849755 jabber:tzafrir.co...@xorcom.com +972-50-7952406 mailto:tzafrir.co...@xorcom.com http://www.xorcom.com iax:gu...@local.xorcom.com/tzafrir ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
This version will hang up the given extension even if it has multiple channels open: asterisk -rx show channels | perl -lane print \asterisk -rx \'soft hangup @F[0]\'\ if m.SIP/201. | bash perl is always your friend when needing some programming mischief :) l. 2009/2/12 Danny Nicholas da...@debsinc.com Here's an improved hack to this bit of trickery: Exten = _86,1,system('/usr/sbin/asterisk -rx soft hangup $(/usr/sbin/asterisk -rx 'core show channels' | grep SIP/${EXTEN(2)| awk '{ print $1 '} )) Where dialing 861234 would hangup extension 1234 If this needs refinement, will repost: -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Helius Ferreira Sent: Thursday, February 12, 2009 4:42 AM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] Hangup extensions via CLI? Asterisk 1.6 implements the hangup on the channel you just made the call and I used it with this command (apparently) asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000| awk '{ print $1 '} ) In my asterisk system: debian*CLI core show channels Channel Location State Application(Data) SIP/7000-09c63a30(None) Up AppDial((Outgoing Line)) SIP/-09c599387...@internos:5 Up Dial(SIP/7000) 2 active channels 1 active call 6 calls processed debian*CLI debian:~# asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000|awk '{ print $1 '} ) SIP/7000-09c63a30 SIP/-09c59938 is not a known channel But, with the channel SIP/-09c59938 is OK. asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/| awk '{ print $1 '} ) Requested Hangup on channel 'SIP/-09c59938' I use asterisk 1.6.1 beta4 On Wed 11 Feb 2009 09:34:12 Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) It basically calls *, gets the list of channels, filters them out to get the channel name and hangs it up. OK, using AMI and a real programming language and hadling multiple lines would be better. Thanks l. 2009/2/9 Tim Nelson tnel...@rockbochs.com Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Loway - home of QueueMetrics - http://queuemetrics.com ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
You guys think YOU'RE overdoing it... your solution works with a single line. My solution was some convoluted 100 line shell script! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 - Lenz Emilitri wrote: I have a feeling we're overdoing it :) l. 2009/2/12 Lukas Rypl r...@marconi.ttc.cz asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000 Hi, I used this way of processing output from asterisk 1.2 and found out that it is not 100% safe because there can appear unprintable characters in the output. This will cause the following grep command to show message similar to Binary content: matched instead of expected line. It is necessary to use strings -a to filter output. So your example should be: asterisk -rx 'core show channels' | strings -a | grep SIP/7000 Hope it helps Lukas ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Loway - home of QueueMetrics - http://queuemetrics.com ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
Asterisk 1.6 implements the hangup on the channel you just made the call and I used it with this command (apparently) asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000| awk '{ print $1 '} ) In my asterisk system: debian*CLI core show channels Channel Location State Application(Data) SIP/7000-09c63a30(None) Up AppDial((Outgoing Line)) SIP/-09c599387...@internos:5 Up Dial(SIP/7000) 2 active channels 1 active call 6 calls processed debian*CLI debian:~# asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000|awk '{ print $1 '} ) SIP/7000-09c63a30 SIP/-09c59938 is not a known channel But, with the channel SIP/-09c59938 is OK. asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/| awk '{ print $1 '} ) Requested Hangup on channel 'SIP/-09c59938' I use asterisk 1.6.1 beta4 On Wed 11 Feb 2009 09:34:12 Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) It basically calls *, gets the list of channels, filters them out to get the channel name and hangs it up. OK, using AMI and a real programming language and hadling multiple lines would be better. Thanks l. 2009/2/9 Tim Nelson tnel...@rockbochs.com Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
Here's an improved hack to this bit of trickery: Exten = _86,1,system('/usr/sbin/asterisk -rx soft hangup $(/usr/sbin/asterisk -rx 'core show channels' | grep SIP/${EXTEN(2)| awk '{ print $1 '} )) Where dialing 861234 would hangup extension 1234 If this needs refinement, will repost: -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Helius Ferreira Sent: Thursday, February 12, 2009 4:42 AM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] Hangup extensions via CLI? Asterisk 1.6 implements the hangup on the channel you just made the call and I used it with this command (apparently) asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000| awk '{ print $1 '} ) In my asterisk system: debian*CLI core show channels Channel Location State Application(Data) SIP/7000-09c63a30(None) Up AppDial((Outgoing Line)) SIP/-09c599387...@internos:5 Up Dial(SIP/7000) 2 active channels 1 active call 6 calls processed debian*CLI debian:~# asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000|awk '{ print $1 '} ) SIP/7000-09c63a30 SIP/-09c59938 is not a known channel But, with the channel SIP/-09c59938 is OK. asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/| awk '{ print $1 '} ) Requested Hangup on channel 'SIP/-09c59938' I use asterisk 1.6.1 beta4 On Wed 11 Feb 2009 09:34:12 Lenz Emilitri wrote: This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) It basically calls *, gets the list of channels, filters them out to get the channel name and hangs it up. OK, using AMI and a real programming language and hadling multiple lines would be better. Thanks l. 2009/2/9 Tim Nelson tnel...@rockbochs.com Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000 Hi, I used this way of processing output from asterisk 1.2 and found out that it is not 100% safe because there can appear unprintable characters in the output. This will cause the following grep command to show message similar to Binary content: matched instead of expected line. It is necessary to use strings -a to filter output. So your example should be: asterisk -rx 'core show channels' | strings -a | grep SIP/7000 Hope it helps Lukas ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
I have a feeling we're overdoing it :) l. 2009/2/12 Lukas Rypl r...@marconi.ttc.cz asterisk -rx soft hangup $(asterisk -rx 'core show channels' | grep SIP/7000 Hi, I used this way of processing output from asterisk 1.2 and found out that it is not 100% safe because there can appear unprintable characters in the output. This will cause the following grep command to show message similar to Binary content: matched instead of expected line. It is necessary to use strings -a to filter output. So your example should be: asterisk -rx 'core show channels' | strings -a | grep SIP/7000 Hope it helps Lukas ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Loway - home of QueueMetrics - http://queuemetrics.com ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
This is a bit of trickery, but could not resist :) This will kill a channel that is connected to SIP/201 asterisk -rx soft hangup $(asterisk -rx 'show channels' | grep SIP/201 | awk '{ print $1 '} ) It basically calls *, gets the list of channels, filters them out to get the channel name and hangs it up. OK, using AMI and a real programming language and hadling multiple lines would be better. Thanks l. 2009/2/9 Tim Nelson tnel...@rockbochs.com Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 -- Loway - home of QueueMetrics - http://queuemetrics.com ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] Hangup extensions via CLI?
Have you looked at soft hangup -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users- boun...@lists.digium.com] On Behalf Of Tim Nelson Sent: Monday, February 09, 2009 3:29 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] Hangup extensions via CLI? Greetings list- I'd like the ability to hangup all calls for a particular extension from the system CLI. I understand this can probably be scripted using the AMI but I'm not familiar on how to do it. Help! Tim Nelson Systems/Network Support Rockbochs Inc. (218)727-4332 x105 ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users