1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Unable to run EXEC or SYSTEM PHP functions under Plesk Linux

Discussion in 'Plesk 10.x for Linux Issues, Fixes, How-To' started by DominicL, Sep 27, 2011.

  1. DominicL

    DominicL Guest

    0
     
    If I run the following script on my Plesk 10.2 linux server:

    $c = system("ls");
    echo "<br />SYSTEM: ".$c;
    $out = array();
    $d = exec("ls",$out);
    echo "<br />EXEC: ".$d;
    echo "<hr /><pre>";
    print_r($out);
    echo "</pre>";


    I get nothing. Well, I get the following:
    SYSTEM:
    EXEC:
    --------------------------------------------------------------------------------

    Array
    (
    )


    However, if I run the script on local WAMP server, it works fine (obviously changing ls for dir).

    I have checked on the web, and the general opinion is that I am running in safe mode. However, checking phpinfo on the plesk server reveals the following:

    Setting - Local - Master

    safe_mode - Off - On
    safe_mode_exec_dir - no value - no value
    safe_mode_gid - Off - Off
    safe_mode_include_dir -no value - no value

    So safe mode is definately off.

    Does anybody know why EXEC or SYSTEM don't work?

    Incidently, the reason I want to use EXEC is because I want to let users do table backups using mysqldump.
     
    Last edited by a moderator: Sep 27, 2011
  2. DominicL

    DominicL Guest

    0
     
    Can I take it from the lack of response that nobody else has a problem in running the PHP EXEC function under Plesk Panel 10?
     
  3. Daga++

    Daga++ Guest

    0
     
    I know this is a couple months later, but I came across your question while searching for the solution to my own problem. Check your settings against the output of phpinfo(). In my case, safe_mode is being forcefully turned on despite my settings to the contrary.

    This "bug" of mine may be caused by my usage of a subdomain or it may be wider than that -- I'm trying to figure it out.
     
  4. danielamocm

    danielamocm Guest

    0
     
    How to detect the problem

    A program cannot executed due to a lot of possibilities, and in some cases you will not know why without redirecting the error channel. exec() only captures the STDOUT, so if an error occurs, you will not get the message. So try to redirect STDERR to STDOUT to get them both. Also would help to check the exit code of the command to see if it was successful.

    Try this code to see the error, where $command is the command you want to exec:

    $c = system($command." 2>&1");
    echo "<br />SYSTEM: ".$c;

    $out = array();
    exec($command." 2>&1",$out,$exitcode);
    echo "<br />EXEC: ( exitcode : $exitcode )";
    echo "<hr /><pre>";
    print_r($out);
    echo "</pre>";

    Solution found at http://www.tek-tips.com/viewthread.cfm?qid=1662412.
     
Loading...