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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is the “chmod” not working

Status
Not open for further replies.

subcomandante

Programmer
Dec 21, 2001
2
US
I have following directory “test” and am trying to change chmod from 755 to 777 as follows:

$f = “ /home/user/cgi-bin/test/
chmod(0777, $f);

Why is it not working?
Is there any other control or enable of this function?
I am going nuts with this issue of “chmod” !
It appears it has mind of its own.
 
sub

This might not be your problem, but your code should be written like this:

$f = '/home/user/cgi-bin/test/';
chmod(0777, $f);
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Sorry!
Yes that was typo only here!
It is as you suggested.

$f = '/home/user/cgi-bin/test/';
 
Be sure that you actually have write permission on the directory to start with or the chmod won't work.

If you are trying to do this via a CGI through a browser, remember that the web daemon must have write permissions to the dir in order for this to be successful.

HTH If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.
 
One thing I have discovered is that 'chmod' is an incredibly slow operation... if you perform it in
a large loop on many files, it will take a long time.
I always start my script with:

umask 0;

And then, if I am creating directories, I say:

mkdir $dir,0777 unless -d $dir;

When I create files, the 'umask' take care of making
the files 0666, I believe.

Not exactly what you asked, but hopefully this helps.
-- Glenn Lewis
 
I don't think the perl chmod command will work on a directory! From reading the documentation, it looks like it only works on a list of FILES. I'd try the unix chmod command instead, using system or backtics to run it. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top