#!/usr/bin/perl
use IO::Socket::INET;

$conference = "1234";
$host = "127.0.0.1";
$port = 5038;
$EOL = "\015\012";
$BLANK = $EOL x 2;
$username="sm50";
$password="sm50";


$remote = IO::Socket::INET->new(
    Proto => 'tcp',   # protocol
    PeerAddr=> $host, # Address of server
    PeerPort=> $port, # port of server
    Reuse   => 1                                                                                                           
);

$remote->autoflush(1);

$command = "Action: login${EOL}";
$command .= "Username: $username${EOL}";
$command .= "Secret: $password${EOL}";
$command .= "Events: off${BLANK}";
command($command);

$command = "Action: Originate${EOL}";
$command .= "Channel: Local/998@default${EOL}";
$command .= "Context: default${EOL}";
$command .= "Exten: 999${EOL}";
$command .= "Priority: 1${EOL}";
$command .= "Callerid: Shoutcast <999>${EOL}";
$command .= "Variable: conference=$conference${BLANK}";
command($command);

$command = "Action: Logoff${BLANK}";
command($command);


sub command {
        my $cmd = @_[0];
        my $buf="";
        print $remote $cmd;
        return $buf;
}

