<div>Jay, </div>
<div> </div>
<div>I just tried the suggested changes... same response.</div>
<div>I tested the script via command-line & it works fine.</div>
<div> </div>
<div>[root@redhat agi-bin]# php test.php</div>
<div>Content-type: text/html</div>
<div>X-Powered-By: PHP/4.3.9</div>
<div> </div>
<div>VERBOSE"There have been"<br>VERBOSE"1 calls made"<br>[root@redhat agi-bin]#</div>
<div> </div>
<div>The permissions are correct:</div>
<div>-rwxr-xr-x 1 root root 1004 Dec 19 23:42 test.php<br> </div>
<div>Any other thoughts?</div>
<div>Thanks,</div>
<div> </div>
<div>bp</div>
<div> </div>
<div><span class="gmail_quote">On 12/19/06, <b class="gmail_sendername">Jay Milk</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:ast-users@skimmilk.net" target="_blank">ast-users@skimmilk.net
</a>> wrote:</span> </div>
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Does the script run from command-line? Without taking a close look at<br>this, the include statements in the function body of connect_db look
<br>potentially messy.<br><br>Also, any output to stdout is interpreted by asterisk as a command, so<br>those fputs statements would be a problem -- do<br>fputs($stdout,"VERBOSE \"There have been\"\n");
<br>fputs($stdout,"VERBOSE \"$row_count calls made\"\n");<br><br>instead.<br><br>William Piper wrote:<br>> List,<br>><br>> I finally decided to break down & start playing with AGI scripts, but
<br>> for the life of me, I can't figure out what I am doing wrong.<br>><br>> Below is a super simple script to run a query in mysql to see how many<br>> call records there are for the extension calling in, then print the
<br>> total in the CLI.<br>><br>> This is all I get on the CLI:<br>> -- Executing AGI("SIP/216-0baa", "test.php") in new stack<br>> -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php
<br>> -- AGI Script test.php completed, returning 0<br>> -- Executing Hangup("SIP/216-0baa", "") in new stack<br>><br>><br>> Here is the script:<br>> #!/usr/bin/php -q<br>> <?php
<br>> ob_implicit_flush(false);<br>> set_time_limit(6);<br>> $stdin = fopen("php://stdin","r");<br>> $stdout = fopen('php://stdout', 'w');<br>><br>> function read() {
<br>> global $stdin, $debug;<br>> $input = str_replace("\n", "", fgets($stdin, 4096));<br>> return $input;<br>> }<br>> function connect_db() {<br>> $database="asteriskcdrdb";
<br>> include("./common.php");<br>> include("./dbconnect.php");<br>> }<br>><br>> // parse agi headers into array<br>> while ($env=read()) {<br>> $env = str_replace("\"","",$env);
<br>> $s = split(": ",$env);<br>> $agi[str_replace("agi_","",$s[0])] = trim($s[1]);<br>> if (($env == "") || ($env == "\n")) {<br>> break;<br>> }
<br>> }<br>><br>> // main program<br>> $clid = $agi[callerid];<br>> connect_db();<br>><br>> $query1 = "SELECT * FROM cdr WHERE dst = '$clid' ";<br>> $query_result1 = @mysql_query($query1);
<br>> $row_count = mysql_num_rows($query_result1);<br>> $row1 = @mysql_fetch_array ($query_result1);<br>><br>> fputs($stdout,"There have been\n");<br>> fputs($stdout,"$row_count calls made\n");
<br>><br>> fflush($stdout);<br>> fclose($stdin);<br>> fclose($stdout);<br>> exit;<br>> ?><br>><br>> There are no debug errors and the query is going through just fine...<br>> and yes, I chmod 755.
<br>> Does anyone have a clue what I am doing wrong?<br>><br>> Thanks,<br>><br>_______________________________________________<br>--Bandwidth and Colocation provided by <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://easynews.com/" target="_blank">
Easynews.com </a>--<br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br> <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">
http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br>