Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing permissions within a file.

Status
Not open for further replies.

emiii0

Programmer
Dec 6, 2006
1
0
0
US
I'm currently working on making a simple message board. The way I have it setup is that everytime the user submits a subfunction creates a random html file and posts the data to it. But of course the user won't be able to view it because it is protected. I was told to throw the commands before the '>' to change the permission..ie open(P, "a+rx>$random.html");...But that is not working. If you can provide any help that would be great!

Thanks for looking!

Gabe
 
I've never heard of that method of changing permissions and I'm pretty sure "open" doesn't support it.

Use the builtin chmod function:
Code:
chmod 0644 "$random.html";
 
You can put a '+' in front of the '<' or '>' to open a file with read/wrie permissions using the open() function. But I am not sure if that actually makes permanent changes to files permissions. Some experimentation would tell if it does or not.

You can use sysopen() and the Fcntl module to create and chmod files at creation:


or simply use the chmod() function as ishnid shows above.

You'r not creating the files in the cgi-bin are you? That could be a problem as the cgi-bin generally restricts access to only scripts.

- Kevin, perl coder unexceptional!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top