AGI script No such file or directory

I would like to run a php AGI script from dialplan, I created the file added the #!/usr/bin/php to the first line, but I got:
/var/www/html/web/functions/call.php,busy: Failed to execute '/var/www/html/web/functions/call.php': No such file or directory
I tried to set the permission to 0777 and the owner to root and asterisk but nothing helps. If I run it from cli it works. The /usr/bin/php also exists. What can be the problem? If I change the first line to #!/usr/bin/php -q there is no error, but the php code not runs.

Are you using the “AGI” command in the dialplan?

Are calling the full path with the AGI call?

Can you paste the few lines of the dialplan?

1 Like

Yes, I’m using the agi command with full path. I also tried to put the script to the /var/lib/asterisk/agi-bin and use only the file name, with no success. This is my dialplan, there are Hungarian words in it, but it is readable.
exten => s,1,NoOp(Kapunyitás!)
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,NoOp(Nyitási hiba, nincs válasz)
exten => s-NOANSWER,n,AGI(/var/www/html/web/functions/call.php,noanswer)
exten => s-BUSY,1,NoOp(Nyitási hiba, Foglalt)
exten => s-BUSY,n,AGI(/var/www/html/web/functions/call.php,busy)
exten => s-ANSWER,1,NoOp(Sikeres nyitás)
exten => s-ANSWER,n,AGI(/var/www/html/web/functions/call.php,answer)

agi set debug on

Only shows the same, No such file or directory.

From a shell

su asterisk -c "/var/www/html/web/functions/call.php"
su asterisk -c " php -f /var/www/html/web/functions/call.php"

the second runs, the first:
bash: /var/www/html/web/functions/call.php: /usr/bin/php^M: bad interpreter: No such file or directory

What is the ^M?

ls -l $(which php)

Okay I got it working!
I changed the line ending in notepad++ to unix and now it works!
Thank you!

All us windows peeps have to learn this the hard way. The requirement is noted in the link I provided above

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.