My problem is with executing any command from my php homepage
Half solved, I got my pythonscript running but futher on the pythonscript does not have permission to execute its modules
but i′m starting to think that the problem is with apache and not php? i tried to run a pythonscript that is actually what i′m going to run in the end, then it seems to run but stops when the script tries to access a txt file looking like this
[stdout] =>
[stderr] => Traceback (most recent call last):
File "pythontest.py", line 4, in ? f = open("(path)/temp.txt", "w")
IOError: [Errno 13] Permission denied: '(path)/temp.txt'
I have tried all different kind of execution methods that i could find exec, system, popen, proc_open almost nothing runs, i can get a string from system("pwd") but system("ls") returns a number 127 or 126. I also tried to run a compiled c program (code below) exec will return an object "Array" but system will only return 127 or 126 as ls does.
Also I tried to get the values out of the "Array" object? from exec but it returns nothing, if I php print_R Array the page won′t load.
the php output is (code below)-> a: , out1: 126, t[[0]: , strlen out: 5, out: Array, t:
no matter how many arguments i actually put in!
the full path to ls gives 126 and just "ls" gives the number 127
i have tested to chmod all files to full permission, from the page.php to test program but it still gives the same output
php safe mode is off
echo '<pre>';
print_r(execute('ls'))
echo '</pre>';
returns
array
(
[stdout] =>
[stderr] => sh: /var/www/html/grndb/upscgenesearch/test1: Permission denied
[return] => 126
)
why does it give me Permission denied when the test1 program has full permission?
<?php
$a = system("/bin/ls",$out1);
echo "a: "; echo $a;
echo ", out1: "; echo $out1;
$t = exec('pwd/test1 aa hh 11',$out);
foreach ($t as &$value) {
echo ($value);
}
echo ", t[[0]: "; echo $t[0];
echo ", strlen out: "; echo strlen($out);
echo ", out: "; echo $out;
echo ", t: "; echo $t;
?>
C source code
int main(int argc, char *argv[])
{
int i;
for(i = 0; i < argc; i++)
printf("arg %d: %s
", i, argv[i]);
return 0;
}
See Question&Answers more detail:
os