Ted
Ted

Reputation: 3885

system() command inside a PHP script - calling a batch file...

I am trying to make a system('touch 1.test'); inside my server.
So I call systest.php:

<?php
      system('touch 1.test');
?>

the file isn't created.

it works perfectly when called through the command line:

/bin/php /public_html/systest.php

and it creates the file 1.test.

Can it be a permissions error? some other kind of security issue?

Any ideas? Thanks!

Upvotes: 0

Views: 74

Answers (1)

Cjmarkham
Cjmarkham

Reputation: 9690

If the folder that the file is to be created in is not owned by Apache and it isn't writable then this will fail.

Make sure it has the correct permissions or it is done in a folder which is owned by apache or created by apache.

Upvotes: 1

Related Questions