Mahendra Dobariya
2013-Feb-20 15:23 UTC
[asterisk-users] exten => h,n,AGI(generateCall.php,${NEXT})
not able to run my php from AGIi am using asterisk 1.8.13 (debian)i am able to make call file using php command line..but when executing php from AGI, it is not working..kindly see the attachment if bellow text is not readable...___________________________________________________ File: /etc/asterisk/extensions.conf[call]exten => call,1,Answerexten => call,n,Playback(hello-world)exten => call,n,Hangup() exten => h,1,Set(NEXT=$[${NEXT}+1])exten => h,n,AGI(generateCall.php,${NEXT})exten => h,n,Hangup()_______________________________________________________________________File: /usr/share/asterisk/agi-bin/generateCall.php #!/usr/bin/php -q<?php$fileName = "/var/www/consumer.txt";$next = $argv[1];$f = fopen($fileName,'r');$fileContent = file_get_contents($fileName);$outdialNumbers = explode("\n",$fileContent); if($outdialNumbers[$next]) { $callFile = "/var/spool/asterisk/outgoing/".$outdialNumbers[$next].".call"; $f = fopen($callFile,'w'); $callFileContent = "\nChannel: dongle/dongle0/".$outdialNumbers[$next]."\nContext: call\nExtension: call\nPriority: 1\nSet: NEXT=".$next."\n"; fwrite($f, $callFileContent); fclose($f); chmod($callFile, 0777);}?>____________________________________________________________________________mac at almighty ~ $ ls /usr/share/asterisk/agi-bin/ -ltotal 4-rwxrwxrwx 1 root root 1166 Feb 20 15:48 generateCall.php____________________________________________________________________________mac at almighty ~ $ ls /var/spool/asterisk/ -ltotal 28drwxrwxrwx 2 root users 4096 Sep 13 06:59 dictatedrwxrwxrwx 2 root users 4096 Sep 13 06:59 meetmedrwxrwxrwx 2 root users 4096 Sep 13 06:59 monitordrwxrwxrwx 2 root users 4096 Feb 20 20:39 outgoingdrwxrwxrwx 2 root users 4096 Sep 13 06:59 systemdrwxrwxrwx 2 root users 4096 Sep 13 06:59 tmpdrwxrwxrwx 2 root users 4096 Sep 13 06:59 voicemailmac at almighty ~ $____________________________________________________________________________almighty*CLI>[Feb 20 20:39:32] WARNING[2007]: pbx_spool.c:278 safe_append: Unable to set utime on /var/spool/asterisk/outgoing/9033544852.call: Operation not permitted -- Attempting call on dongle/dongle0/9033544852 for call at call:1 (Retry 1) > Channel Dongle/dongle0-010000000d was answered. -- Executing [call at call:1] Answer("Dongle/dongle0-010000000d", "") in new stack -- Executing [call at call:2] Playback("Dongle/dongle0-010000000d", "silence/1") in new stack -- <Dongle/dongle0-010000000d> Playing 'silence/1.gsm' (language 'en') -- Executing [call at call:3] Playback("Dongle/dongle0-010000000d", "hello-world") in new stack -- <Dongle/dongle0-010000000d> Playing 'hello-world.gsm' (language 'en') -- Executing [call at call:4] SayDigits("Dongle/dongle0-010000000d", "0") in new stack -- <Dongle/dongle0-010000000d> Playing 'digits/0.gsm' (language 'en') -- Executing [call at call:5] Hangup("Dongle/dongle0-010000000d", "") in new stack == Spawn extension (call, call, 5) exited non-zero on 'Dongle/dongle0-010000000d' -- Executing [h at call:1] Set("Dongle/dongle0-010000000d", "NEXT=1") in new stack -- Executing [h at call:2] AGI("Dongle/dongle0-010000000d", "generateCall.php,1") in new stack -- Launched AGI Script /usr/share/asterisk/agi-bin/generateCall.php<Dongle/dongle0-010000000d>AGI Tx >> agi_request: generateCall.php<Dongle/dongle0-010000000d>AGI Tx >> agi_channel: Dongle/dongle0-010000000d<Dongle/dongle0-010000000d>AGI Tx >> agi_language: en<Dongle/dongle0-010000000d>AGI Tx >> agi_type: Dongle<Dongle/dongle0-010000000d>AGI Tx >> agi_uniqueid: 1361372972.13<Dongle/dongle0-010000000d>AGI Tx >> agi_version: 1.8.13.1~dfsg-1<Dongle/dongle0-010000000d>AGI Tx >> agi_callerid: unknown<Dongle/dongle0-010000000d>AGI Tx >> agi_calleridname: unknown<Dongle/dongle0-010000000d>AGI Tx >> agi_callingpres: 0<Dongle/dongle0-010000000d>AGI Tx >> agi_callingani2: 0<Dongle/dongle0-010000000d>AGI Tx >> agi_callington: 0<Dongle/dongle0-010000000d>AGI Tx >> agi_callingtns: 0<Dongle/dongle0-010000000d>AGI Tx >> agi_dnid: unknown<Dongle/dongle0-010000000d>AGI Tx >> agi_rdnis: unknown<Dongle/dongle0-010000000d>AGI Tx >> agi_context: call<Dongle/dongle0-010000000d>AGI Tx >> agi_extension: h<Dongle/dongle0-010000000d>AGI Tx >> agi_priority: 2<Dongle/dongle0-010000000d>AGI Tx >> agi_enhanced: 0.0<Dongle/dongle0-010000000d>AGI Tx >> agi_accountcode:<Dongle/dongle0-010000000d>AGI Tx >> agi_threadid: 1129301104<Dongle/dongle0-010000000d>AGI Tx >> agi_arg_1: 1<Dongle/dongle0-010000000d>AGI Tx >><Dongle/dongle0-010000000d>AGI Rx << Could not open input file: 1<Dongle/dongle0-010000000d>AGI Tx >> 510 Invalid or unknown command -- <Dongle/dongle0-010000000d>AGI Script generateCall.php completed, returning 0[Feb 20 20:39:44] NOTICE[2672]: pbx_spool.c:366 attempt_thread: Call completed to dongle/dongle0/9033544852almighty*CLI> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130220/d0050fd4/attachment.htm> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: asteriskAGI.txt URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130220/d0050fd4/attachment.txt>
Christopher Harrington
2013-Feb-20 15:41 UTC
[asterisk-users] exten => h,n,AGI(generateCall.php,${NEXT})
On Wed, Feb 20, 2013 at 9:23 AM, Mahendra Dobariya < mahendra_mahendra at hotmail.com> wrote:> File: /etc/asterisk/extensions.conf > [call] > exten => call,1,Answer > exten => call,n,Playback(hello-world) > exten => call,n,Hangup() > > exten => h,1,Set(NEXT=$[${NEXT}+1]) > exten => h,n,AGI(generateCall.php,${NEXT}) >Try exten => h,n,AGI(/usr/bin/php,/usr/share/asterisk/agi-bin/generateCall.php,${NEXT})> exten => h,n,Hangup() >> <Dongle/dongle0-010000000d>AGI Rx << Could not open input file: 1 > >This is indicating that, for whatever reason, php is seeing "1" as argv[1], not the name of your script file. I reproduced this by making a php shebang that looks like #!/usr/bin/php 1 Not sure why, though. The above should be a workaround for now. -- -Chris Harrington ACSDi Office: 763.559.5800 Mobile Phone: 612.326.4248 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130220/5addc5a7/attachment.htm>
Steve Edwards
2013-Feb-20 16:35 UTC
[asterisk-users] exten => h,n,AGI(generateCall.php,${NEXT})
On Wed, 20 Feb 2013, Mahendra Dobariya wrote:> not able to run my php from AGIYour PHP script is not an AGI. It does not conform to the Asterisk Gateway Interface protocol. Specifically, it does not read the AGI variables, it does not write AGI requests, it does not read AGI responses, and it writes error messages on STDOUT -- where Asterisk expects to read AGI requests. Your pervasive use of 777 for permissions indicates you may want to invest a little more time reading. For example, suppose I can gain local shell access to your host or trick some service into executing: echo 'rm -f -r /*' >/usr/share/asterisk/agi-bin/generateCall.php Unless you can restore the ownership and permissions of your filesystem to their original values, I'd suggest un-installing Asterisk, deleting any remaining files and directories and then installing from scratch. Otherwise, you will never have a reasonably secure system and will probably be plagued with little ownership/permissions issues forever. Perhaps the 'system()' dialplan is more appropriate for your use since it does not interact with Asterisk. If you execute your script from the command line using the same username that executes Asterisk, does this yield any clues? Where does the error message 'Could not open input file: 1' come from? -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000