shell_exec fails - mehtinks it is permission related...

Posted on 2007-10-03
Last Modified: 2008-01-09
I am trying to use PHP to reload the extensions in an Asterisk installation. I keep getting this error:

Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist?) when I run the script by visiting the URL; however, if I run the script from the command line, it runs just fine (works perfect, actually).

I think it is permissions related. Does anyone have any ideas?

        $output = shell_exec('asterisk -rx"extensions reload"');
        echo $output;
Question by:DrDamnit
    LVL 51

    Expert Comment

    use full path for asterisk, there might also be a configuration file probably used from the current user's home directory
    LVL 32

    Accepted Solution

    Figured out the problem. PHP runs as nobody and only root has access to asterisk. I ended up using phpagi to restart the asterisk service.
    LVL 1

    Expert Comment

    Closed, 500 points refunded.
    Community Support Moderator

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now