Hi firiends, Sorry for a basic question here. I am trying to write an agi script using php. Nothing fancy just simple script first. I call the php script from the extensions.conf exten => 91234/1001,1,Wait,1 exten => 91234/1001,2,AGI,test.agi exten => 91234/1001,3,Hangup php script is ; #!/usr/bin/php -q <?php ob_implicit_flush(true); set_time_limit(6); $stdout = fopen('php://stdout', 'w'); fwrite($stdout,"STREAM FILE demo-congrats" ); fflush($stdout); ?> * telles me "Error in Argument 1, char 3, option not found. ". script can be run from command line. Appreciate some help to get going here. Dough -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20040306/7c84a2e4/attachment.htm
On Sat, 6 Mar 2004, Doug Harris wrote:> * telles me "Error in Argument 1, char 3, option not found. ". > > script can be run from command line. > > Appreciate some help to get going here.I can't find any error like this in the asterisk source code, perhaps your error is coming from php? James
your code: #!/usr/bin/php -q <?php ob_implicit_flush(true); set_time_limit(6); $stdout = fopen('php://stdout', 'w'); fwrite($stdout,"STREAM FILE demo-congrats" ); fflush($stdout); ?> The error message is generated by PHP... If your PHP version is higher that v4.3.0 line 5: $stdout = fopen('php://stdout', 'w'); should be $stdout = fopen(STDOUT, 'w'); I suspect that is the problem, as everything else looks file. ----- Original Message ----- From: Doug Harris To: Asterisk-Users@Lists. Digium. Com Sent: Saturday, March 06, 2004 11:07 AM Subject: [Asterisk-Users] new2agi -php Hi firiends, Sorry for a basic question here. I am trying to write an agi script using php. Nothing fancy just simple script first. I call the php script from the extensions.conf exten => 91234/1001,1,Wait,1 exten => 91234/1001,2,AGI,test.agi exten => 91234/1001,3,Hangup php script is ; #!/usr/bin/php -q <?php ob_implicit_flush(true); set_time_limit(6); $stdout = fopen('php://stdout', 'w'); fwrite($stdout,"STREAM FILE demo-congrats" ); fflush($stdout); ?> * telles me "Error in Argument 1, char 3, option not found. ". script can be run from command line. Appreciate some help to get going here. Dough -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20040306/899afa60/attachment.htm
Hi, Thanks for the insight. I am using PHP 4.2. So I guess code is still good. There arn't much code there so I played with it. I ran the same code with only the line #!/usr/bin/php -q and it shows me the same error. So I think the script don't even get run. My php is in /usr/bin so path is correct. I wonder whether there is any permision or something missing here. When agi is run by asterisk, does it run as root ? thanks a bunch. doug From: "Derek Bruce" <dbruce@calgarytelecom.com> To: <asterisk-users@lists.digium.com> Subject: Re: [Asterisk-Users] new2agi -php Date: Sat, 6 Mar 2004 16:06:09 -0700 Reply-To: asterisk-users@lists.digium.com This is a multi-part message in MIME format. ------=_NextPart_000_004E_01C40394.F061F050 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable your code: #!/usr/bin/php -q <?php ob_implicit_flush(true); set_time_limit(6); $stdout =3D fopen('php://stdout', 'w'); fwrite($stdout,"STREAM FILE demo-congrats" ); fflush($stdout); ?> The error message is generated by PHP... If your PHP version is higher that v4.3.0 line 5: $stdout =3D fopen('php://stdout', 'w'); should be $stdout =3D fopen(STDOUT, 'w'); I suspect that is the problem, as everything else looks file.
Hi,> -----Original Message----- > I am trying to write an agi script using php. Nothing fancy > just simple script first. > > I call the php script from the extensions.conf > > exten => 91234/1001,1,Wait,1 > exten => 91234/1001,2,AGI,test.agi > exten => 91234/1001,3,HangupHmm, sure you don't need to Answer somewhere ?> #!/usr/bin/php -q > <?php > ob_implicit_flush(true); > set_time_limit(6); > $stdout = fopen('php://stdout', 'w'); > fwrite($stdout,"STREAM FILE demo-congrats" ); fflush($stdout); ?> > > * telles me "Error in Argument 1, char 3, option not found. ". > > script can be run from command line.STREAM FILE takes one more argument: The keys that will interrupt playback. In my scripts, if not using any keys, I simply use 'X'. So STREAM FILE demo-congrats becomes STREAM FILE demo-congrats X. Maybe (not sure) you also need a \n at the endo of your fwrite... I'm not sure if that will do the trick, but if the file permissions (execution bit) and all is set properly, I think it should do. Florian
Hi> > Thanks for the insight. I am using PHP 4.2. So I guess code is still good. >use php 4.3.x (latest is better), since in the 4.2 php cli (eg for scripts) is beta and could give problems. since 4.3.x cli is built by default and is much better for sys scripts. matteo. -- Brancaleoni Matteo <mbrancaleoni@espia.it> Espia - Emmegi Srl
Hi Philipp, It seems like line #!/usr/local/bin/php -q cretes the error. I have this file test.php #!/usr/local/bin/php -q <?php echo "hello world"; ?> And when I run this from command line, I get this error; "Error in argument 1, char 3: option not found" [root@asterisk agi-bin]# ./test.php Error in argument 1, char 3: option not found Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] php <file> [args...] -a Run interactively -C Do not chdir to the script's directory -c <path>|<file> Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f <file> Parse <file>. Implies `-q' -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -q Quiet-mode. Suppress HTTP Header output. -s Display colour syntax highlighted source. -v Version number -w Display source with stripped comments and whitespace. -z <file> Load Zend extension <file>. [root@asterisk agi-bin]# I upgraded my PHP to version 4.3.4, still the same result. [root@asterisk agi-bin]# /usr/local/bin/php -v PHP 4.3.4 (cgi) (built: Mar 7 2004 14:39:01) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies When I change the first line to #!/usr/local/bin/php -c, it will run the test.php but result comes with HTML headers. I am sure this is not an issue with asterisk, I guess I have to post this to a php forum :). Anyway I just want to close the loop. Thanks for help here. Doug> -----Original Message----- > From: Philipp von Klitzing > [mailto:klitzing@pool.informatik.rwth-aachen.de] > Sent: Sunday, March 07, 2004 4:17 AM > To: Doug Harris > Subject: Re: [Asterisk-Users] new2agi -php > > > Hi there, > > also read this: > http://home.cogeco.ca/~camstuff/agi.html#STREAMFILE > > Cheers, Philipp > >