i created a file by the following code
$dir = '/home/srikanth/Desktop';
if ( !file_exists($dir) ) {
mkdir ($dir, 0777);
}
//$code contains the code C code which i want to execute
file_put_contents ($dir.'/test.c', $code);
$path = "/home/srikanth/Desktop/test.c";
$Command = "gcc $path 2&>1";
exec($Command,$return_val,$error);
when i open my error log file i see the following error
sh: 1: cannot create 1: Permission denied
gcc: error: 2: No such file or directory
i tried the following commands to change the permission ,I am currently using Ubuntu 14.04.2 and Apache server
chmod 0777 /home/srikanth/Desktop/test.c
sudo chmod -R 777 /home/srikanth/Desktop/test.c
sudo usermod -aG www-data root
addgroup www-data
I used these commands to add www-data to root group but i still keep on getting the same file in my error log