#!/usr/bin/perl -w

use strict;
use Socket;

my $ast_sock = '/var/run/asterisk/asterisk.ctl';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
connect(SOCK, sockaddr_un($ast_sock)) ||
	die "$0: Freepbxdb: Failed connecting to $ast_sock\n: $!";
while (<STDIN>) {
	chomp;
	# Note: commands are NULL-terminated:
	print SOCK "$_\0";
	sleep 0.001;
}
close(SOCK) or
	die "$0: Failed sending commands ($ast_sock): $!\n";

__END__

=head1 NAME

astcmd - simple replacement for asterisk -rx

astcmd reads commands from the standard input and executes commands. Their
output is ignored.
