Newbie - Auto-create file with chmod

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I don't use database for storing user details (or anything else) because
there is not much data anyway, but I would like to automatize process
when I need a new chmod666 file on server. By now I created file
manually and then changed attributes to 666.

How can I create file when it's needed (script cannot find it so it
creates it) and chmod it to 666?

I guess there is a way to do it, but I just don't know it :-)

Re: Newbie - Auto-create file with chmod

Quoted text here. Click to load it

umask()? Or write your own createFileAndChown().

Re: Newbie - Auto-create file with chmod

use the copy() command thus:

copy ("existing_holder_file.txt","destination/new_file_name.csv");

exisiting_holder_file.txt needs to exist before the script is run, but
it can be an empty file.  Use this function at the end of the code,
once you are done writing the file you need.  if you are editing: read
the existing file into the script, edit it and save it away as
existing_holder_file.txt with the "w" switch (which empties the file
and overwrites it).  Then copy the file with the above code to the
location and filename of your choice.  You can call a cdmod after it is

Site Timeline