Last active
December 5, 2017 19:54
-
-
Save PotcFdk/ba413f308f48eb220bf4032fd709e213 to your computer and use it in GitHub Desktop.
Revisions
-
PotcFdk revised this gist
May 13, 2016 . 1 changed file with 86 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,86 @@ #!/bin/bash OLDIFS=$IFS ask() { # http://djm.me/ask while true; do if [ "${2:-}" = "Y" ]; then prompt="Y/n" default=Y elif [ "${2:-}" = "N" ]; then prompt="y/N" default=N else prompt="y/n" default= fi # Ask the question - use /dev/tty in case stdin is redirected from somewhere else read -p "$1 [$prompt] " REPLY </dev/tty # Default? if [ -z "$REPLY" ]; then REPLY=$default fi # Check if the reply is valid case "$REPLY" in Y*|y*) return 0 ;; N*|n*) return 1 ;; esac done } function trim { echo -n "$@" | sed 's/^[[:space:]]*(.+)[[:space:]]*$/\\1/' } while [ true ]; do # Main check Loop echo "Connecting..." nc 192.168.2.1 1012 | while read line; do declare -a info echo -n "* " IFS=';' read -r -a info <<< "$line" time=${info[0]} cmd=${info[1]} connection_id=${info[2]} echo -n "$time " | tee -a $LOGFILE if [ $cmd = "RING" ]; then caller=${info[3]} dest=${info[4]} method=${info[5]} echo "[RING] incoming from $caller to us, $dest, via $method" | tee -a $LOGFILE elif [ $cmd = "CALL" ]; then msn=${info[3]} src=${info[4]} dest=${info[5]} method=${info[5]} echo "[CALL] outgoing to $dest from us, $src->$msn, via $method" | tee -a $LOGFILE elif [ $cmd = "CONNECT" ]; then msn=${info[3]} dest=${info[4]} echo "[CONNECT] established connection with $dest" | tee -a $LOGFILE elif [ $cmd = "DISCONNECT" ]; then duration=${info[3]} echo "[DISCONNECT] connection terminated" | tee -a $LOGFILE else >&2 echo "Unknown command: $line (this shouldn't happen)" fi done done -
PotcFdk created this gist
May 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ #