Re: [asterisk-users] AGI Help Please
Below are a few errors in the script and on a google search, although I found people with the same error, I didn't find a resolution. Any thoughts on what is causing this error? Any thoughts as to why the output is not showing on the CLI without doing a debug? snip Content-type: text/html X-Powered-By: PHP/4.3.9 These 2 lines should not be there. AGI Tx AGI Rx AGI Tx 510 Invalid or unknown command AGI Rx AGI Tx 510 Invalid or unknown command These 2 errors are probably caused by the Content-type and X-Powered-By lines. AGI Rx VERBOSEThere have been AGI Tx 510 Invalid or unknown command AGI Rx VERBOSE125 calls made AGI Tx 510 Invalid or unknown command According to this page http://www.voip-info.org/wiki/view/verbose Usage: Verbose(message [level]) Also, you usually put error_reporting(0); at the top of the script so you won't have warnings and errors confusing Asterisk. I never wrote a PHP AGI without using this : http://phpagi.sourceforge.net/ so I can't help you much You should give it a try, you might like it :) hth ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
Try running it as ./test.php the hash-bang should take care of the php-location. The first two lines are one cause of your problem. Could be the lack of the -q param for php. However, I would expect the script to not show anything, as it should be reading params from asterisk first. Iirc, asterisk is picky about the order in which commands are accepted -- sending commands (such as VERBOSE) before pulling its output buffer, could be problematic. William Piper wrote: Jay, I just tried the suggested changes... same response. I tested the script via command-line it works fine. [EMAIL PROTECTED] agi-bin]# php test.php Content-type: text/html X-Powered-By: PHP/4.3.9 VERBOSEThere have been VERBOSE1 calls made [EMAIL PROTECTED] agi-bin]# The permissions are correct: -rwxr-xr-x 1 root root 1004 Dec 19 23:42 test.php Any other thoughts? Thanks, bp On 12/19/06, *Jay Milk* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Does the script run from command-line? Without taking a close look at this, the include statements in the function body of connect_db look potentially messy. Also, any output to stdout is interpreted by asterisk as a command, so those fputs statements would be a problem -- do fputs($stdout,VERBOSE \There have been\\n); fputs($stdout,VERBOSE \$row_count calls made\\n); instead. William Piper wrote: List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
Does the script run from command-line? Without taking a close look at this, the include statements in the function body of connect_db look potentially messy. Also, any output to stdout is interpreted by asterisk as a command, so those fputs statements would be a problem -- do fputs($stdout,VERBOSE \There have been\\n); fputs($stdout,VERBOSE \$row_count calls made\\n); instead. William Piper wrote: List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
I am running console. I'm a newbie for AGI's but not that new. Thanks, bp On 12/19/06, Tzafrir Cohen [EMAIL PROTECTED] wrote: On Tue, Dec 19, 2006 at 09:35:56AM +0200, yusuf wrote: to see debug output for AGI's, you *must* be connected to the first Ast terminal. So start Asterisk like 'asterisk -cvv', then you will see output from your AGI. Actually, if you have not started Asterisk in a console, it will be sent to the first remote client. Thus you won't exit Asterisk if you accidentally press Ctrl-C, as you're used to ;-) -- Tzafrir Cohen icq#16849755jabber:[EMAIL PROTECTED] +972-50-7952406 mailto:[EMAIL PROTECTED] http://www.xorcom.com iax:[EMAIL PROTECTED]/tzafrir ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
Jay, I just tried the suggested changes... same response. I tested the script via command-line it works fine. [EMAIL PROTECTED] agi-bin]# php test.php Content-type: text/html X-Powered-By: PHP/4.3.9 VERBOSEThere have been VERBOSE1 calls made [EMAIL PROTECTED] agi-bin]# The permissions are correct: -rwxr-xr-x 1 root root 1004 Dec 19 23:42 test.php Any other thoughts? Thanks, bp On 12/19/06, Jay Milk [EMAIL PROTECTED] wrote: Does the script run from command-line? Without taking a close look at this, the include statements in the function body of connect_db look potentially messy. Also, any output to stdout is interpreted by asterisk as a command, so those fputs statements would be a problem -- do fputs($stdout,VERBOSE \There have been\\n); fputs($stdout,VERBOSE \$row_count calls made\\n); instead. William Piper wrote: List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, ___ --Bandwidth and Colocation provided by Easynews.com http://easynews.com/ -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
Ok, further testing shows that the AGI is apparently running however the information is still not displaying on the CLI. Below are a few errors in the script and on a google search, although I found people with the same error, I didn't find a resolution. Any thoughts on what is causing this error? Any thoughts as to why the output is not showing on the CLI without doing a debug? Thanks -- Executing AGI(SIP/216-e866, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php AGI Tx agi_request: test.php AGI Tx agi_channel: SIP/216-e866 AGI Tx agi_language: en AGI Tx agi_type: SIP AGI Tx agi_uniqueid: 1166590405.17780 AGI Tx agi_callerid: 216 AGI Tx agi_calleridname: Billy Test AGI Tx agi_callingpres: 0 AGI Tx agi_callingani2: 0 AGI Tx agi_callington: 0 AGI Tx agi_callingtns: 0 AGI Tx agi_dnid: 255 AGI Tx agi_rdnis: unknown AGI Tx agi_context: admin AGI Tx agi_extension: 255 AGI Tx agi_priority: 1 AGI Tx agi_enhanced: 0.0 AGI Tx agi_accountcode: test216 AGI Tx AGI Rx AGI Tx 510 Invalid or unknown command AGI Rx AGI Tx 510 Invalid or unknown command AGI Rx VERBOSEThere have been AGI Tx 510 Invalid or unknown command AGI Rx VERBOSE125 calls made AGI Tx 510 Invalid or unknown command -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-e866, ) in new stack On 12/19/06, William Piper [EMAIL PROTECTED] wrote: Jay, I just tried the suggested changes... same response. I tested the script via command-line it works fine. [EMAIL PROTECTED] agi-bin]# php test.php Content-type: text/html X-Powered-By: PHP/4.3.9 VERBOSEThere have been VERBOSE1 calls made [EMAIL PROTECTED] agi-bin]# The permissions are correct: -rwxr-xr-x 1 root root 1004 Dec 19 23:42 test.php Any other thoughts? Thanks, bp On 12/19/06, Jay Milk [EMAIL PROTECTED] wrote: Does the script run from command-line? Without taking a close look at this, the include statements in the function body of connect_db look potentially messy. Also, any output to stdout is interpreted by asterisk as a command, so those fputs statements would be a problem -- do fputs($stdout,VERBOSE \There have been\\n); fputs($stdout,VERBOSE \$row_count calls made\\n); instead. William Piper wrote: List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, ___ --Bandwidth and Colocation provided by Easynews.com http://easynews.com/-- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
[asterisk-users] AGI Help Please
List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, bp ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
William Piper wrote: List, I finally decided to break down start playing with AGI scripts, but for the life of me, I can't figure out what I am doing wrong. Below is a super simple script to run a query in mysql to see how many call records there are for the extension calling in, then print the total in the CLI. This is all I get on the CLI: -- Executing AGI(SIP/216-0baa, test.php) in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test.php -- AGI Script test.php completed, returning 0 -- Executing Hangup(SIP/216-0baa, ) in new stack Here is the script: #!/usr/bin/php -q ?php ob_implicit_flush(false); set_time_limit(6); $stdin = fopen(php://stdin,r); $stdout = fopen('php://stdout', 'w'); function read() { global $stdin, $debug; $input = str_replace(\n, , fgets($stdin, 4096)); return $input; } function connect_db() { $database=asteriskcdrdb; include(./common.php); include(./dbconnect.php); } // parse agi headers into array while ($env=read()) { $env = str_replace(\,,$env); $s = split(: ,$env); $agi[str_replace(agi_,,$s[0])] = trim($s[1]); if (($env == ) || ($env == \n)) { break; } } // main program $clid = $agi[callerid]; connect_db(); $query1 = SELECT * FROM cdr WHERE dst = '$clid' ; $query_result1 = @mysql_query($query1); $row_count = mysql_num_rows($query_result1); $row1 = @mysql_fetch_array ($query_result1); fputs($stdout,There have been\n); fputs($stdout,$row_count calls made\n); fflush($stdout); fclose($stdin); fclose($stdout); exit; ? There are no debug errors and the query is going through just fine... and yes, I chmod 755. Does anyone have a clue what I am doing wrong? Thanks, bp Hi, to see debug output for AGI's, you *must* be connected to the first Ast terminal. So start Asterisk like 'asterisk -cvv', then you will see output from your AGI. -- thanks, yusuf -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI Help Please
On Tue, Dec 19, 2006 at 09:35:56AM +0200, yusuf wrote: to see debug output for AGI's, you *must* be connected to the first Ast terminal. So start Asterisk like 'asterisk -cvv', then you will see output from your AGI. Actually, if you have not started Asterisk in a console, it will be sent to the first remote client. Thus you won't exit Asterisk if you accidentally press Ctrl-C, as you're used to ;-) -- Tzafrir Cohen icq#16849755jabber:[EMAIL PROTECTED] +972-50-7952406 mailto:[EMAIL PROTECTED] http://www.xorcom.com iax:[EMAIL PROTECTED]/tzafrir ___ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users