Skip to content

Instantly share code, notes, and snippets.

View heron-brito's full-sized avatar

Heronmb heron-brito

View GitHub Profile
@anpel
anpel / originate_call.php
Last active December 12, 2022 17:54
Originate a call from Asterisk using PHP and Asterisk Manager Interface
/**
* Once this scipt is executed it will connect to the local port you have assigned to
* Asterisk (default: 5038) and send an authentication request. If successfull, it will
* send a second request to originate your call.
*
* The internal SIP line $internalPhoneline will be dialed, and when picked up the
* $target phone will be dialed using your outbound calls context ($context).
*
* Of course, you can modify the commands sent to the asterisk manager interface to suit your needs.
* you can find more about the available options at:
@pkuczynski
pkuczynski / parse_yaml.sh
Last active April 9, 2024 18:36
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}