#!/usr/bin/php -q exec_dial($argv[1], $argv[2], 1, $options=NULL, $url=NULL); $retval = $agi->get_variable("DIALSTATUS"); // here returns ok, $retval['result'] == 1 if($retval['result'] == 1){ if($retval['data'] != "ANSWER"){ $start_time = date("U"); $agi->exec_dial($argv[3], $argv[4], 20, $options=NULL, $url=NULL); $stop_time = date("U"); $retval = $agi->get_variable("DIALSTATUS"); // here is the problem, $retval['result'] == -1 (wtf is -1 ?) if($retval['result'] == 0){ if($retval['data'] == "ANSWER"){ $p = ceil(($stop_time-$start_time)/60)*0.035; } } } } $agi->hangup(); ?>