Monday, March 4, 2019

amazon web services - PHP on Ubuntu AWS Server: POPEN fails with “sh: : not found”

I am moving my current website over to Amazon AWS from a Red Hat shared server. When I moved my working code, I started to receive an error in my popen call.



The error is: sh: 1: : not found



I found a similar question 5 years ago but there was never really a good answer. popen fails with "sh: : not found"




I use XAMPP on my ubuntu 14.04 laptop for a local testbed and the problem does not arise there, but it does on my AWS instance. Using ubuntu 14.04lts with php5 and apache2 on the instance.



I suspect it might be a PHP setting or path problem but everything I tried has failed, any suggestions?



output = shell_exec('echo abc'); worked fine.



Here is some more info: My Code:



if (file_exists(SitePATH."/solver/dkcube")){

//echo "Executable is there
";
error_reporting(E_ALL);
$handle = popen("$runvariable 2>&1","r");
echo "Line 1: '$handle'; ".gettype($handle). "
";
$contents = stream_get_contents($handle);
echo "Line 2: $contents"; pclose($handle);


The runvariable is basically the dkcube from the file_exists with some pass through variables. The echo for Line 2 is




'Line 2: sh: 1: /var/www/html/solver/dkcube: not found'



Hopefully that gives you some more info.



I tried the sudo -H -u php_user sh -c 'content of runvariable here' and it returned the same error: sh: 1: /var/www/html/solver/dkcube: not found

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...