Hi guys .. <br><br>I am a total noob on all this FS and asterisk thing .. <br>I have a system already running on Asterisk and i want to migrate it to FS<br>I have an AGI made in perl that runs everytime and i need to be at least pointed out on how i can approach on transferring this to FS<br>
<br>Here is the AGI .. its simple ...<br><br><br>#!/usr/bin/perl<br>use Asterisk::AGI;<br>use DBI;<br>use strict;<br><br>my $AGI = new Asterisk::AGI;<br>my %input = $AGI->ReadParse();<br>$input{'callerid'} =~ /(^.+<(\d+)>$)|((^\d+$))/;<br>
$input{'calleridani'} = $2 || $3;<br>#my $userid = $input{'calleridani'};<br>my $userid=$input{'extension'};<br>#my $userid='1001';<br># Config options<br>my %MYSQL = (<br> hostname => "localhost",<br>
username => "callmeuser",<br> password => "mycallmepass",<br> database => "executives"<br>);<br><br>my $dbh = DBI->connect("dbi:mysql:$MYSQL{database}:$MYSQL{hostname}","$MYSQL{username}","$MYSQL{password}")|| die("Couldn't connect to database!\n"); <br>
#============<br>$AGI->verbose("Connected to database.");<br>$AGI->verbose("Call for : $userid");<br>#======<br><br><br> print STDERR "$userid";<br> print STDERR "hello testing db connected";<br>
my $debug=2;<br>my $phone="";<br>#debug("Connect to database");<br>#debug("Transferred call, using original cid: $name",5);<br>my $str ="select phone from timetable where exten='$userid' and online='Y' ";<br>
$AGI->verbose("Checking if $userid is online right now and get his phone number from db.");<br>$AGI->verbose("$str");<br>print STDERR "$str";<br>my $sth =$dbh->prepare($str);<br>$sth->execute || die("Couldn't exec sth2!");<br>
#my $pin = $sth->fetchrow_hashref;<br>#print STDERR "xxxx";<br>#print STDERR "$pin";<br><br>while (my @row = $sth->fetchrow_array)<br>{<br>$phone = $row[0];<br>print STDERR "xxxx";<br>print STDERR "$phone";<br>
print STDERR "vvvvx";<br>$AGI->verbose("$userid is online and his phone number is $phone");<br>#$AGI->exec('DIAL', "SIP/$phone");<br> }<br>if ($phone!="")<br><br>{<br>
$AGI->verbose("Calling $userid at $phone");<br>my $dialstr="SIP/$phone"."@"."209.9.9.34";<br>$AGI->set_callerid(7347777777);<br><br>$AGI->exec('DIAL', $dialstr);<br>
my $st=$AGI->get_full_variable('status',$dialstr);<br>$AGI->verbose("channel status is : $st");<br>}<br><br>else<br><br>{<br>$AGI->verbose("$userid is not online.");<br>#$AGI->stream_file('custom/myrecording');<br>
$AGI->stream_file('followme/sorry');<br>$AGI->stream_file('en/vm-nobodyavail');<br>}<br><br>$AGI->hangup();<br><br><br>Thanks everyone for all the help.<br>Ed<br>