Crmgo Blog

Bash script for call transfer

Bash script for call transfer

#!/bin/bash context="from-internal" # set the context to which we will transfer the call exten=$1 # get the operator's number num=$2 # get the external or internal number to which the transfer will be made bridge=$(asterisk -rx 'core show channels concise' | grep SIP/$exten -…

Bash script for call transfer

#!/bin/bash context="from-internal" # set the context to which the call will be transferred exten=$1 # get the operator's extension num=$2 # get the external or internal number to which the transfer will be made bridge=$(asterisk -rx 'core show channels concise' | grep SIP/$exten- | cut -d '!' -f13 ) # get the bridge-id for the channel whose name is in the format SIP/xx-aaaaa channel=$(asterisk -rx 'core show channels concise' | grep $bridge | grep -v SIP/$exten- | cut -d '!' -f1) # get the channel connected to it in the format SIP/provider-000000 result=$(asterisk -rx "channel redirect $channel $context,$num,1") # redirect the obtained channel to the required context echo $result exit 0

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.