Sam Hawkin
2009-May-09 04:47 UTC
[asterisk-users] Unable to run asterisk CLI commands from php
Hi All, I am trying to run the asterisk CLI commands from php. Some thing like "asterisk -rx reload". But it is not working, where as when I try to run linux "ls" command it works fine. below is sample php code which I am trying to run. $command = "sudo asterisk -rx reload"; $value1 = system($command,$retval1); $value2 = exec($command,$retval2); echo $value1; echo $value2; can any one suggest what might be the problem and possible solution to it. Any help is highly appreciated. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090509/616722f3/attachment.htm
Tzafrir Cohen
2009-May-09 05:07 UTC
[asterisk-users] Unable to run asterisk CLI commands from php
On Sat, May 09, 2009 at 10:17:27AM +0530, Sam Hawkin wrote:> Hi All, > > I am trying to run the asterisk CLI commands from php. > Some thing like "asterisk -rx reload". > But it is not working, where as when I try to run > linux "ls" command it works fine. > > below is sample php code which I am trying to run. > > $command = "sudo asterisk -rx reload"; > > $value1 = system($command,$retval1); > $value2 = exec($command,$retval2); > > echo $value1; > echo $value2; > > can any one suggest what might be the problem and possible solution to it.Yes. What error do you actually get? You need to get stderr from hte command as well for that. What version of Asterisk do you use, BTW? -- Tzafrir Cohen icq#16849755 jabber:tzafrir.cohen at xorcom.com +972-50-7952406 mailto:tzafrir.cohen at xorcom.com http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
Steve Edwards
2009-May-09 16:30 UTC
[asterisk-users] Unable to run asterisk CLI commands from php
On Sat, 9 May 2009, Sam Hawkin wrote:> I am trying to run the asterisk CLI commands from php. > > Some thing like "asterisk -rx reload". > > $command = "sudo asterisk -rx reload"; > > $value1 = system($command,$retval1);Without any output or error messages its hard to guess... In what context is your PHP script executing? 1) As an AGI? 2) By you from a shell? 3) From cron? There are (at least) 4 elements to consider: 1) Does your script have the execute permission set? 2) Does the executing process have a "clear path" to your script? (Do all of the directories in the path to your script allow the executing process to execute your script.) 3) Is /usr/sbin/ in the path of the executing process? 4) Is the user running the script authorized to run sudo with no password? Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000