Jump to content

Exec with Swetest output is not displayed on Browser but works locally


Recommended Posts

Dear all,

I need help urgently. Please review the below code. 

<?php
error_reporting(E_ALL);
error_reporting(-1);
// phpinfo();
if(@exec('echo EXEC') == 'EXEC'){
        echo 'exec works';
        $ram=array();
        echo exec("whoami");
        exec("swetest -b$20.06.1998 -ut02.40.00 -p0123456789DAttt -eswe -house40,37,p -flsj -g -head", $ram);
        //shell_exec("swetest -b$20.06.1998 -ut02.40.00 -p0123456789DAttt -eswe -house40,37,p -flsj -g -head");
        print_r($ram);
        }
?>

This Array Ram is empty Array{} when I run in in URL on browser but when I run the same PHP code on Putty Linux Terminal, it gives below result.  

(
    [0] =>  69.4699711    0.9589330      12.7711722
    [1] =>  137.2047430  12.6210423       3.6491743
    [2] =>  57.5155629    2.0043804      12.4929126
    [3] =>  31.3153898    1.1640522      11.8892585
    [4] =>  64.9341541    0.7061970      12.6475111
    [5] =>  354.5698247   0.1370835      10.9268075
    [6] =>  29.0617305    0.1066860      11.8413060
    [7] =>  312.6691481  -0.0108831       9.4849388
    [8] =>  301.9767792  -0.0136113       9.0252288
    [9] =>  246.6157497  -0.0273073       7.0543078
    [10] =>  223.8406492         -0.0627669       6.1963588
    [11] =>  198.5784533          0.1113581       5.6143622
    [12] =>  155.4844488         -0.0261982       4.3224287
    [13] =>  155.4844488         -0.0261982       4.3224287
    [14] =>  155.4844488         -0.0261982       4.3224287
    [15] =>  78.0000935   4.3224287
    [16] =>  99.9959839   4.3224287
    [17] =>  121.4227768          4.3224287
    [18] =>  146.1570660          4.3224287
    [19] =>  178.0430227          4.3224287
    [20] =>  218.1001694          4.3224287
    [21] =>  258.0000935          4.3224287
    [22] =>  279.9959839          4.3224287
    [23] =>  301.4227768          4.3224287
    [24] =>  326.1570660          4.3224287
    [25] =>  358.0430227          4.3224287
    [26] =>  38.1001694   4.3224287
    [27] =>  78.0000935   4.3224287
    [28] =>  326.1570660          4.3224287
    [29] =>  328.3998653          4.3224287
    [30] =>  220.1804870          4.3224287
)
 

It is Exec permission issue or Swetest 32 bit issue or 64 bit issue. Output comes on terminal while on browser the array is empty. Please advice. 

I am using Cpanel with Alamlinux 9 on a VPS. 

 

Link to comment
Share on other sites

  • 1 month later...

Additionally to the potential problems pointed out by requinix, there is also the possibility that "swetest" is not available in the path, so the user that php is running as (and this depends on your environment ie. are you running apache with mod_php or are you running php-fpm or what) either does not have permissions or again can't find program.  First thing I would suggest is making sure you specify the full path to swetest.  The other thing you should do is include a 3rd parameter to exec.  If will also return boolean false on exec error, so:

 

if (false === exec("swetest -b$20.06.1998 -ut02.40.00 -p0123456789DAttt -eswe -house40,37,p -flsj -g -head", $ram, $returnCode)) {
   echo "Failed with $returnCode";
   die();
}
echo '<pre>' . print_r($ram)  . '</pre>';

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.