Lookup full channel name from dial plan

I want to perform a channel redirect from dial plan.
For this reason I have to get the full name of a specific channel, of which I only know the peer involved, e.g., from channel SIP/5313-00008fea I know 5313, of PJSIP/5314-000025a6 I know 5314.

How do I lookup a full channel name from dial plan in such a scenario?

The device dialing into the dial plan that executes the redirect and looks up the channel name is not connected to the channel I want to get information on.

In other words, e.g. peer 5315 is on a call. How do I retrieve its channel name from a dial plan application?

The channel needs to save its name in a database entry or global variable.

1 Like

using dial plan shell function you can run this command core show channel | grep PJSIP/5315, but you will need to do some more sting filters

1 Like

I am trying to grep only the channel name from core show channel.
There is a different behaviour if I execute the command from bash or via system from dial plan.

asterisk -x "core show channels" | grep -oh "\w*/8700-\w*" from bash returns what I would want, i.e. the full channel name:

If I run the command via system from dial plan I do not get the same result.
exten => test,1,System(asterisk -x "core show channels" | grep "\w*/8700-\w*" > /tmp/ch.txt)

I get only /8700-

Do you have an idea why that would be?

Use the CHANNELS function. https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Function_CHANNELS

1 Like

Is the channels function a recent addition to Asterisk?
Doesn’t look like it’s working on my Asterisk 13 installs.

I’m using it with machines running a much earlier version of Asterisk.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.