#!/usr/bin/perl # Path to multimon $mm = "/usr/local/bin/multimon-ng -q -a DTMF"; # Tone/DTMF strings to trigger on $on1_str = "555"; $on2_str = "666"; # Commands or scripts to execute $on1_cmd = "echo 555 received"; $on2_cmd = "echo 666 received"; select STDOUT; $| = 1; $i = 0; sub System { if ((0xffff & system $args) != 0 ) { print STDERR "error: $!\n"; exit 1; } } open M, "$mm |" || die "Can't open $mm: $!\n"; while () { ($a, $b) = split ':'; $b =~ tr/0-9*#ABCD//csd; # Allow 0-9 * # A B C D $ans .= $b; $i++; if ($i == (length $on1_str)) { if ($ans eq $on1_str) { System($args = $on1_cmd); undef $ans; $i = 0; } if ($i == (length $on2_str)) { if ($ans eq $on2_str) { System($args = $on2_cmd); undef $ans; $i = 0; } else { undef $ans; $i = 0; } } } }