top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Exec and system do not work in PHP

+1 vote
40 views

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");

This does not -

if( !file_exists("/var/www/orders.txt"));
{
 $out = system("touch /var/www/orders.txt", $ret);
 $out2 = system("chmod 766 /var/www/orders.txt", $ret);
 echo 'file2
';
 echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
 exec("touch /var/www/orders.txt");
 exec("chmod 766 /var/www/orders.txt");
 echo 'file2
';
 echo file_exists("/var/www/orders.txt");
}
posted Aug 26, 2013 by Kumar Mitrasen

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Is there a reason you're using shell commands to achieve the following:
Also, why are you setting the executable bit on a text file? :)

1 Answer

+1 vote

*/var/www* is usually under *www* user. It may be a permissions problem.

answer Aug 26, 2013 by Abhay Kulkarni
Similar Questions
0 votes

I always ran my php files as /localhost/myfile.php. Now the system cannot find the files. It says "waiting for local host" and stays in an infinite loop. All the files are in /var/www.

+1 vote

Do we have any users of Php say 5.6 on a FreeBSD 10.3 system installed from ports?

If so, can you get in touch with me? I'm trying to install pear and not having much luck, getting an error about a missing peclcmd.php file and a zlib extension that make is complaining about but which is in my php install.


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...