Voxilla VoIP Forum

Go Back   Voxilla VoIP Forum > Hardware/Software Support Forums > Asterisk Support Forum

Asterisk Support Forum Technical support, how-to guides, troubleshooting, and general assistance, from beginner to seasoned pro, this is where to discuss Asterisk, the most powerful open source PBX.


Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old August 18th, 2007, 10:42 AM
PaperBirdMaster's Avatar
Junior Member
 
Join Date: Aug 2007
Location: Spain
Posts: 1
PaperBirdMaster is on a distinguished road
Send a message via MSN to PaperBirdMaster
Question Trying to create my first IVR

Hello friends.

First, I must tell that I am really sorry cause my english skill is really poor but I try to explain my question

I'm new on Asterisk world (I was using Asterisk for my own purposes for 1 year ago) and now I'm trying to build an IVR that saves into a database the keypresses; first, I create a context to hold the IVR

Code:
[mycontext]
exten => s,1,Answer
exten => s,2,AGI(test1.php)
exten => s,3,Background(press-1-for-castellano)
exten => s,4,Wait(1)
exten => s,5,Background(press-2-for-catala)

;--------- CASTELLANO ---------
exten => 1,1,Background(Gracias)
exten => 1,2,Wait(1)

exten => 1,3,Background(esp/intro-answer-1)
exten => 1,4,Read(tmp,esp/answer-1,1)
exten => 1,5,Set(RESPA=${tmp}|g)
exten => 1,6,Background(Gracias)

exten => 1,7,Background(esp/intro-answer-2)
exten => 1,8,Read(tmp,esp/answer-2,1)
exten => 1,9,Set(RESPB=${tmp}|g)
exten => 1,10,Background(Gracias)

exten => 1,11,Set(LANG=1|g)
exten => 1,12,Hangup

;--------- CATALA ---------
exten => 2,1,Background(Gracies)
exten => 2,2,Wait(1)

exten => 2,3,Background(cat/intro-answer-1)
exten => 2,4,Read(tmp,esp/answer-1,1)
exten => 2,5,Set(RESPA=${tmp}|g)
exten => 2,6,Background(Gracies)

exten => 2,7,Background(cat/intro-answer-2)
exten => 2,8,Read(tmp,cat/answer-2,1)
exten => 2,9,Set(RESPB=${tmp}|g)
exten => 2,10,Background(Gracies)

exten => 2,11,Set(LANG=2|g)
exten => 2,12,Hangup

; -- HANGUP --
exten => h,1,DeadAGI(test2.php|${LANG}|${RESPA}|${RESPB})
exten => h,2,Hangup
exten => i,1,Goto(s,3)
exten => o,1,Goto(s,3)
I was tested that menu and it works... but seems that the scripts (test1.php and test2.php) does'nt work... i think that the system do not execute it.

The scritps are the following:

Test1.php
Code:
#!/usr/bin/php -q 
<?
ob_implicit_flush(false); 
error_reporting(0); 
set_time_limit(300); 

$log = "/var/log/asterisk/test1.txt";

$stdlog = fopen($log, 'a');
$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');

while (!feof($stdin))
{
    $inputvalue = fgets($stdin);
    fputs($stdlog, "From stdin: " . $inputvalue . "\n");

    $inputvalue = str_replace("\n", "", $inputvalue);

    $partes = explode(":", $inputvalue);
    $agivar[$partes[0]] = trim($partes[1]);
    fputs($stdlog, "agivar[" . $partes[0] . "] = " . trim($partes[1]) . "\n");

    if (($inputvalue == "") || ($inputvalue == "\n")) break;
}

fclose($stdin);
fclose($stdlog);  
exit;

?>
Test2.php
Code:
#usr/bin/php -q 
<?
ob_implicit_flush(false); 
error_reporting(0); 
set_time_limit(300); 

$debug = 1; 
$log = "/var/log/asterisk/test2.txt";

$stdlog = fopen($log, 'a');
$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');

if ($debug) :
    fputs($stdlog, "Script log.\n\n" . date("F j, Y - H:i:s"));
endif;

// Code begins here
while (!feof($stdin))
{
    $inputvalue = fgets($stdin);
    if ($debug) fputs($stdlog, "from stdin: " . $inputvalue);

    $inputvalue = str_replace("\n", "", $inputvalue);

    $partes = explode(":", $inputvalue);
    $agivar[$partes[0]] = trim($partes[1]);

    if (($inputvalue == "") || ($inputvalue == "\n")) break;
}

$LANG = $_SERVER['argv'][1];
$LANG = trim($TLF);
$LANG = ltrim($TLF);

$RESPA = $_SERVER['argv'][2];
$RESPA = trim($RESPA);
$RESPA = ltrim($RESPA);

$RESPB = $_SERVER['argv'][3];
$RESPB = trim($RESPA);
$RESPB = ltrim($RESPA);

if ($debug) :
    fputs($stdlog, "LANG: " . $LANG . "\n");
    fputs($stdlog, "RESPA: " . $RESPA . "\n");
    fputs($stdlog, "RESPB: " . $RESPB . "\n");
    fputs($stdlog, "\n\nOpening database...\n"); 
endif;

$link = mysql_connect("localhost", "root", "passw0rd") or die("Data base connection failed");
mysql_select_db("testdatabase") or die("data base open failed");

if ($debug) :
    fputs($stdlog, "Database opened\n");
endif;

$query = "INSERT INTO `test_table` VALUES (" . $TLF . ", `" . $RESPA . "`, `" . $RESPB . "`, `" . $RESPC . "`)";
$result = mysql_db_query($query) or die("Web site query failed");

if ($debug) :
    fputs($stdlog, "the query is: " . $query . "\n");

    if ($result)
    {    fputs($stdlog, "query done.\n");}
    else
    {    fputs($stdlog, "query failed.\n");}
endif;

if ($debug) :
    fputs($stdlog, "... closing database.\n");
endif;

mysql_close($link);

if ($debug) :
    fputs($stdlog, "Script log.\n\n" . date("F j, Y - H:i:s")); 
endif;

fclose($stdlog);
fclose($stdin);
fclose($stdlog);  
exit;

?>
Both files have execution permisions (0755) and the owner is asterisk:asterisk but, i know that the code is'nt executed cause the log files are not created and the database stays empty, where is my error?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get (or create) SIP numbers? khalidev General VoIP Discussion 2 September 5th, 2007 07:48 PM
How to create a profile for Linksys SPA-3102/Sipura 3000 phermi Linksys (Sipura) VoIP Support Forum 0 June 13th, 2007 09:08 PM
Need help to create dial plan (pstn # and FWD #) lifeisfun Linksys (Sipura) VoIP Support Forum 1 January 19th, 2006 10:35 PM
create an extension to soundcard in aah? rotary500 Asterisk Support Forum 2 January 17th, 2006 05:05 PM
How to create more than 4 gateways in SPA3K bsharif Linksys (Sipura) VoIP Support Forum 6 May 26th, 2005 05:06 AM


Voxilla News

More Voxilla news



All times are GMT. The time now is 02:02 AM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Logos and trademarks are the property of Voxilla or their respective owner. All other content © 2003-2009 by Voxilla, Inc.