[asterisk-users] asterisk 1.6 agi problem with PHP

2011-07-16 Thread Zarko Zivanovic
Hello everyone,

I am sure that someone can help with this. We decided to do a fresh install
of asterisk 1.6.2.19

And after we did that, the problem that we have is this - We cant run a
single Php file!

 

Here's the output:

 

-- Executing [8212@from-pstn:1] Answer(DAHDI/23-1, ) in new stack

-- Executing [8212@from-pstn:2] AGI(DAHDI/23-1, testera.agi) in new
stack

-- Launched AGI Script /var/lib/asterisk/agi-bin/testera.agi

DAHDI/23-1AGI Tx  agi_request: testera.agi

DAHDI/23-1AGI Tx  agi_channel: DAHDI/23-1

DAHDI/23-1AGI Tx  agi_language: en

DAHDI/23-1AGI Tx  agi_type: DAHDI

DAHDI/23-1AGI Tx  agi_uniqueid: 1310825293.10

DAHDI/23-1AGI Tx  agi_version: 1.6.2.19

DAHDI/23-1AGI Tx  agi_callerid: 112686649

DAHDI/23-1AGI Tx  agi_calleridname: unknown

DAHDI/23-1AGI Tx  agi_callingpres: 3

DAHDI/23-1AGI Tx  agi_callingani2: 0

DAHDI/23-1AGI Tx  agi_callington: 33

DAHDI/23-1AGI Tx  agi_callingtns: 0

DAHDI/23-1AGI Tx  agi_dnid: 8212

DAHDI/23-1AGI Tx  agi_rdnis: unknown

DAHDI/23-1AGI Tx  agi_context: from-pstn

DAHDI/23-1AGI Tx  agi_extension: 8212

DAHDI/23-1AGI Tx  agi_priority: 2

DAHDI/23-1AGI Tx  agi_enhanced: 0.0

DAHDI/23-1AGI Tx  agi_accountcode:

DAHDI/23-1AGI Tx  agi_threadid: -1223132272

DAHDI/23-1AGI Tx 

DAHDI/23-1AGI Rx  verbose Failed to execute
'/var/lib/asterisk/agi-bin/testera.agi': No such file or directory 1

testera.agi: Failed to execute '/var/lib/asterisk/agi-bin/testera.agi': No
such file or directory

DAHDI/23-1AGI Tx  200 result=1

 

 

VERIFIED EVERYTHING:

 

[root@localhost agi-bin]# ls -l

total 48

-rwxr-xr-x 1 asterisk asterisk  1742 Jul  1 18:57 agi-test.agi

-rwxr-xr-x 1 asterisk asterisk  9909 Jul  1 18:57 eagi-sphinx-test

-rwxr-xr-x 1 asterisk asterisk  8724 Jul  1 18:57 eagi-test

-rwxr-xr-x 1 asterisk asterisk 14530 Jul  1 18:57 jukebox.agi

-rwxr-xr-x 1 asterisk asterisk  1508 Jul 16 16:04 testera.agi

 

[root@localhost agi-bin]# which php

/usr/bin/php

 

 

 

 

 

 

 

Here's the agi - simple  test that we picked from the net.:

 

#!/usr/bin/php

?

  ob_implicit_flush(false);

  set_time_limit(6);

  $stdin = fopen('php://stdin', 'r');

  $stdlog = fopen('my_agi.log', 'w');

   $debug = true;

   /* Read input from Asterisk and output via $astOutput */

   function astRead()

   {

  global $stdin, $debug, $stdlog;

  $astOutput = str_replace(\n, , fgets($stdin, 4096));

  if ($debug) fputs($stdlog, read: $input\n);

  return $astOutput ;

   }

   /* Write AGI command to Asterisk */

   function astWrite($agiCommand)

   {

  global $debug, $stdlog;

  if ($debug) fputs($stdlog, write: $agiCommand\n);

  echo $agiCommand.\n;

   }

   /* Handling execution input from Asterisk */

   $agivar = array();

   while (!feof($stdin))

   {

$temp = fgets($stdin);

$temp = str_replace(\n,,$temp);

$s = explode(:,$temp);

$agivar[$s[0]] = trim($s[1]);

if ($temp == )

   {

 break;

}

   }

  /* Operational Code starts here */

  /* Playback the demo-congrats.gsm file from the

 

* directory /var/lib/asterisk/sounds/

*/

  astWrite(STREAM FILE /var/lib/asterisk/sounds/en/tt-monkeys #);

  astRead();

  /* Say the number 123456

  astWrite(SAY NUMBER 123456 #);

  astRead();*/

  /* Finalization of AGI script and clean-ups */

  fclose ($stdin);

  fclose ($stdlog);

  exit(0);

?

 

 

All help is appreciated.

 

Thanks,

Z. Zivanovic

 

 

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] asterisk 1.6 agi problem with PHP

2011-07-16 Thread Steve Edwards

On Sat, 16 Jul 2011, Zarko Zivanovic wrote:

I am sure that someone can help with this. We decided to do a fresh 
install of asterisk 1.6.2.19 And after we did that, the problem that we 
have is this – We cant run a single Php file!


testera.agi: Failed to execute '/var/lib/asterisk/agi-bin/testera.agi': 
No such file or directory


If you try to execute the script as the user running the Asterisk binary 
from the command line, what do you get?


For example:

sudo -s -u asterisk
/var/lib/asterisk/agi-bin/testera.agi /dev/null

If that executes, I'd take a peek at the environment variables of the 
Asterisk process to ensure /usr/bin/ is in the PATH.


For example:

sudo cat /proc/$(pidof asterisk)/environ\
| tr '\0' '\n'\
| grep PATH

Keep in mind, an AGI interfaces with Asterisk via STDIN and STDOUT so you 
can test an AGI (within obvious limitations) completely outside of 
Asterisk by redirecting STDIN and STDOUT. For example, given a file 
testera.stdin containing:


agi_request: testera.agi
agi_channel: DAHDI/23-1
agi_language: en
agi_type: DAHDI
agi_uniqueid: 1310825293.10
agi_version: 1.6.2.19
agi_callerid: 112686649
agi_calleridname: unknown
agi_callingpres: 3
agi_callingani2: 0
agi_callington: 33
agi_callingtns: 0
agi_dnid: 8212
agi_rdnis: unknown
agi_context: from-pstn
agi_extension: 8212
agi_priority: 2
agi_enhanced: 0.0
agi_accountcode:
agi_threadid: -1223132272

200 result=0
200 result=0
200 result=0

You can execute the AGI like:

/var/lib/asterisk/agi-bin/testera.agi testera.stdin

and your script should display:

STREAM FILE /var/lib/asterisk/sounds/en/tt-monkeys #

which, obviously, will not succeed because your AGI is 'talking' to your 
shell, not Asterisk.


--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users