Stefan-Michael. Guenther (in-put GbR)
2006-Aug-08 02:55 UTC
[asterisk-users] AGI doesn't execute PHP5 script
Hi, I'm trying to start a PHP5 script via the AGI Interface. The asterisk version is Asterisk 1.2.5-BRIstuffed-0.3.0-PRE-1k and I followed the instructions on http://www.voip-info.org/tiki-print.php?page=Asterisk+AGI+php The problem is, as you can see from the output in the CLI, that Asterisk claims that it executes the script, but nothing happens. It doesn't create the file /tmp/asterisk and it doesn't send an email. When I execute the script manually on the command line, it is execute without an error, the file is there and the email, too. ###################################################### ;extensions.conf ; [guenther] exten => 111,1,Answer() exten => 111,2,AGI(test.php) exten => 111,3,Hangup ###################################################### ls -l /var/lib/asterisk/agi-bin/test.php -rwxr-xr-x 1 asterisk root 340 Aug 8 10:07 test.php ###################################################### cat /var/lib/asterisk/agi-bin/test.php #! /usr/bin/php5 <?php ob_implicit_flush(false); set_time_limit(6); error_reporting(0); system("touch /tmp/asterisk"); $header="From: Asterisk <Asterisk@localhost>\nX-OTRS-Queue:Misc\n"; $subject="Anruf vom SysAdmin"; mail("otrs@localhost",$subject,"Testemail","From: Asterisk <Asterisk@localhost>"); ?> ###################################################### asterisk*CLI> dial 111@guenther -- Executing Answer("OSS/dsp", "") in new stack << Console call has been answered >> -- Executing AGI("OSS/dsp", "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: OSS/dsp AGI Tx >> agi_language: en AGI Tx >> agi_type: Console AGI Tx >> agi_uniqueid: asterisk-6958-1155024459.47 AGI Tx >> agi_callerid: unknown AGI Tx >> agi_calleridname: unknown AGI Tx >> agi_callingpres: 0 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: unknown AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: guenther AGI Tx >> agi_extension: 111 AGI Tx >> agi_priority: 2 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: AGI Tx >> LI> -- AGI Script test.php completed, returning 0 -- Executing Hangup("OSS/dsp", "") in new stack << Hangup on console >> ###################################################### When I use a shell script instead of the PHP script, everything works as expected, the file /tmp/asterisk is created: cat /var/lib/asterisk/agi-bin/test.sh #! /bin/bash echo "1" > /tmp/asterisk ###################################################### Obviously, PHP5 is the problem, but what's wrong with it? Thanks for your help, Stefan -- ******************************************** in-put GbR - Das Linux-Systemhaus Stefan-Michael Guenther Moltkestrasse 49 D-76133 Karlsruhe Tel./Fax : +49 (0)721 / 83044 - 98/93 http://www.in-put.de ******************************************** Schulungen Installationen Beratung Support Voice-over-IP-Loesungen ******************************************** -- ******************************************** in-put GbR - Das Linux-Systemhaus Stefan-Michael Guenther Moltkestrasse 49 D-76133 Karlsruhe Tel./Fax : +49 (0)721 / 83044 - 98/93 http://www.in-put.de ******************************************** Schulungen Installationen Beratung Support Voice over IP - L?sungen ********************************************
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stefan-Michael. Guenther (in-put GbR) wrote:> Hi, > > I'm trying to start a PHP5 script via the AGI Interface. > The asterisk version is Asterisk 1.2.5-BRIstuffed-0.3.0-PRE-1k and I followed > the instructions on > > http://www.voip-info.org/tiki-print.php?page=Asterisk+AGI+php > > The problem is, as you can see from the output in the CLI, that Asterisk > claims that it executes the script, but nothing happens. It doesn't create > the file /tmp/asterisk and it doesn't send an email. > When I execute the script manually on the command line, it is execute without > an error, the file is there and the email, too. > > ###################################################### > ;extensions.conf > ; > [guenther] > exten => 111,1,Answer() > exten => 111,2,AGI(test.php) > exten => 111,3,Hangup > > ###################################################### > ls -l /var/lib/asterisk/agi-bin/test.php > > -rwxr-xr-x 1 asterisk root 340 Aug 8 10:07 test.php > > ###################################################### > > cat /var/lib/asterisk/agi-bin/test.php > #! /usr/bin/php5 > > <?php > ob_implicit_flush(false); > set_time_limit(6); > error_reporting(0);Try running it from the command line and see what happens - -- Cheers, Matt Riddell _______________________________________________ http://www.sineapps.com/news.php (Daily Asterisk News - html) http://freevoip.gedameurope.com (Free Asterisk Voip Community) http://www.sineapps.com/rssfeed.php (Daily Asterisk News - rss) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE2Hh3S6d5vy0jeVcRAkf7AJ0bbLWCZXQ/ismZJxG2l2vfMCktiQCfeshM Sk03IFfNGOdKGM9CZvsrldE=CNyN -----END PGP SIGNATURE-----
Hello Stefan-Michael., You ,need to use #!/usr/bin/php5 -q insted off #! /usr/bin/php5 i guess. Tuesday, August 8, 2006, 2:55:10 PM, you wrote:> Hi,> I'm trying to start a PHP5 script via the AGI Interface. > The asterisk version is Asterisk 1.2.5-BRIstuffed-0.3.0-PRE-1k and I followed > the instructions on> http://www.voip-info.org/tiki-print.php?page=Asterisk+AGI+php> The problem is, as you can see from the output in the CLI, that Asterisk > claims that it executes the script, but nothing happens. It doesn't create > the file /tmp/asterisk and it doesn't send an email. > When I execute the script manually on the command line, it is execute without > an error, the file is there and the email, too.> ###################################################### > ;extensions.conf > ; > [guenther]exten =>> 111,1,Answer() exten =>> 111,2,AGI(test.php) exten =>> 111,3,Hangup> ###################################################### > ls -l /var/lib/asterisk/agi-bin/test.php> -rwxr-xr-x 1 asterisk root 340 Aug 8 10:07 test.php> ######################################################> cat /var/lib/asterisk/agi-bin/test.php > #! /usr/bin/php5> <?php > ob_implicit_flush(false); > set_time_limit(6); > error_reporting(0); > system("touch /tmp/asterisk"); > $header="From: Asterisk <Asterisk@localhost>\nX-OTRS-Queue:Misc\n"; > $subject="Anruf vom SysAdmin"; > mail("otrs@localhost",$subject,"Testemail","From: Asterisk > <Asterisk@localhost>");?>>> ######################################################asterisk*CLI>> dial 111@guenther> -- Executing Answer("OSS/dsp", "") in new stack > << Console call has been answered >> > -- Executing AGI("OSS/dsp", "test.php") in new stack > -- Launched AGI Script /var/lib/asterisk/agi-bin/test.phpAGI Tx >>> agi_request: test.php AGI Tx >>> agi_channel: OSS/dsp AGI Tx >>> agi_language: en AGI Tx >>> agi_type: Console AGI Tx >>> agi_uniqueid: asterisk-6958-1155024459.47 AGI Tx >>> agi_callerid: unknown AGI Tx >>> agi_calleridname: unknown AGI Tx >>> agi_callingpres: 0 AGI Tx >>> agi_callingani2: 0 AGI Tx >>> agi_callington: 0 AGI Tx >>> agi_callingtns: 0 AGI Tx >>> agi_dnid: unknown AGI Tx >>> agi_rdnis: unknown AGI Tx >>> agi_context: guenther AGI Tx >>> agi_extension: 111 AGI Tx >>> agi_priority: 2 AGI Tx >>> agi_enhanced: 0.0 AGI Tx >>> agi_accountcode: AGI Tx >>> LI>> -- AGI Script test.php completed, returning 0 > -- Executing Hangup("OSS/dsp", "") in new stack > << Hangup on console >>> ###################################################### > When I use a shell script instead of the PHP script, everything works as > expected, the file /tmp/asterisk is created:> cat /var/lib/asterisk/agi-bin/test.sh > #! /bin/bashecho "1" >> /tmp/asterisk> ######################################################> Obviously, PHP5 is the problem, but what's wrong with it?> Thanks for your help,> Stefan > --> ******************************************** > in-put GbR - Das Linux-Systemhaus > Stefan-Michael Guenther > Moltkestrasse 49 D-76133 Karlsruhe > Tel./Fax : +49 (0)721 / 83044 - 98/93 > http://www.in-put.de > ******************************************** > Schulungen Installationen > Beratung Support > Voice-over-IP-Loesungen > ********************************************-- Best regards, Vahram
Stefan-Michael. Guenther (in-put GbR)
2006-Aug-09 02:13 UTC
[asterisk-users] AGI doesn't execute PHP5 script [SOLVED]
Hi, I have solved it (but don't understand yet, why it works)!!! SuSE 10.1 uses different configuration files for the cli version and the cgi version of PHP5. When I modify the first line in the script from #! /usr/bin/php5 to #! /usr/bin/php5 -c /etc/php5/cli/ the php scripts gets executed! I guess I have to compare the parameters in the two configuration files to get the important detail.>> AGI Tx >> agi_accountcode: >> AGI Tx >> LI> >> ? ? -- AGI Script test.php completed, returning 0 >> ? ? -- Executing Hangup("OSS/dsp", "") in new stack >> ?<< Hangup on console >> >> >> And it doesn't make a difference whether I use the dial command or a sip >>phone >> to call extension 111 in context [guenther]. Strange, isn't it?>Yeah. ?That response is usually when things are not happening properly. >Matt, the ouput hasn't changed, although ist script is executed properly. Why do you thing that this output shows a failure?>Also are you using php -q? >No, this isn't required for php5 (taken from README.CLI): * CLI is started up in quiet mode by default. (-q switch kept for compatibility) Thanks for your help and suggestions, Stefan -- ******************************************** in-put GbR - Das Linux-Systemhaus Stefan-Michael Guenther Moltkestrasse 49 D-76133 Karlsruhe Tel./Fax : +49 (0)721 / 83044 - 98/93 http://www.in-put.de ******************************************** Schulungen Installationen Beratung Support Voice over IP - L?sungen ********************************************