From The CLI, How Can I Hangup A Channel Name That Includes A Space Character?

Home » Asterisk Users » From The CLI, How Can I Hangup A Channel Name That Includes A Space Character?
Asterisk Users 3 Comments

I have a customer who named their endpoint to include a space (example, 1003 a)

From the CLI, I want to hangup a channel on this endpoint

From core show channels concise, I see the channel name includes the space PJSIP/1003 a-00000002

I realize the space is interpreted as an argument separator, so my first attempt below doesn’t work. I have tried the following and all fail.

hangup request PJSIP/1003 a-00000002
hangup request ‘PJSIP/1003 a-00000002’
hangup request “PJSIP/1003 a-00000002”
hangup request PJSIP/1003%20a-00000002
hangup request PJSIP/1003&nbspa-00000002

Is there some control character(s) for the CLI to interpret everything in between as a single argument?

Dan

3 thoughts on - From The CLI, How Can I Hangup A Channel Name That Includes A Space Character?

  • I think you can typically use tab completion when working with spaces or you can escape the space with a back slash

    For example Doug Lytle would be

    Doug\ Lytle

    Doug

  • Thanks Doug.

    Turns out if using hangup request does not work with the escaped character CLI> hangup request PJSIP/1003\ a-00000007
    Usage: channel request hangup |
    Request that a channel be hung up. The hangup takes effect
    the next time the driver reads or writes from the channel.
    If ‘all’ is specified instead of a channel name, all channels
    will see the hangup request.

    However, channel request hangup … does support the escaped character. CLI> channel request hangup PJSIP/1003\ a-00000007
    Requested Hangup on channel ‘PJSIP/1003 a-00000007’

    Thank you for the help.

    Dan

    —–Original Message—

  • We think the reason hangup request does not work is because it’s an alias. We are using the default cli_aliases.conf which supports hangup request calling channel request hangup. We think the alias detects the arguments correctly, but then passes the argument without the escaped character (or double quotes) to the real CLI command.

    We found that double quotes also work for channel request hangup “…”

    It would be nice if the CLI alias commands would pass arguments (or at least some arguments) with double quotes. That would allow the hangup request alias to work exactly as the channel request hangup that it calls.

    —–Original Message—