mt2k has asked for the wisdom of the Perl Monks concerning the following question:

Can someone help me with this?
When creating a directory or when using chmod on a directory, the permissions do not work.
I have no access to the directory, meaning no new directories or files cannot be added to directory.
I have to go in and set them manually using an ftp program.
I have even tried giving the directory full permissions (777), yet it still does not work!

Please help!

Replies are listed 'Best First'.
Re: Chmod
by btrott (Parson) on May 03, 2000 at 04:36 UTC
    Are you using 0777, or 777? Try 0777.

    0777 makes sense as a permission setting, and 777 doesn't. Numerical permissions are specified in octal, not decimal; so 777 is actually the permission 01411, which is different than what you want, I'd suspect. :)

      I have heard that some web servers (apache) don't run scripts if they have beeen chmod:ed too liberal, out of security reasons. Chmod 711 works for me.

      One thing i wonder abt, how _shoud_ I chmod directories, html files et.c.
      I've seen people (who knows more about unix systems than me) reaching files or directories higher up in the tree from the web.

      /wonko

      To clarify for those used to the unix command...chmod(0NNN, $file) is not the same as "# chmod 0NNN $file" run from a shell. Perl interprets the value as octal because of the leading 0. So if you're trying to get g+s, you'll need to use 02NNN or oct(2NNN).
RE: Chmod
by BBQ (Curate) on May 03, 2000 at 06:37 UTC
    btrott is right as usual, but also check what your umask is... If its set to the system's default (022) you'll neve get anything better than 755 on chmod. Have you tried doing:
    umask(0000); chmod(0777,'whatever') or warn();
    It might do the trick... You can't chmod above your umask limit.

    #!/home/bbq/bin/perl
    # Trust no1!
      Actually, the umask merely sets the default permissions. If you use chmod, you can set the permissions to anything you want (assuming you own the file).
        You're absolutely right! My bad...

        At first, when I read your post, I though, "This can't be right! I've been doing this for ages now!" And then I tested it:
        johnny@chthon:~/tmp > mkdir foobar johnny@chthon:~/tmp > ls -l total 1 drwxr-xr-x 2 johnny users 1024 May 4 07:10 foobar johnny@chthon:~/tmp > perl -e 'umask(0666); chmod(0777,'foobar');' johnny@chthon:~/tmp > l total 4 drwxr-xr-x 3 johnny users 1024 May 4 07:10 ./ drwx------ 12 johnny users 2048 May 3 23:09 ../ drwxrwxrwx 2 johnny users 1024 May 4 07:10 foobar/ johnny@chthon:~/tmp >
        'nough said! I've been doing it wrong for ages... Thanks!
RE: Chmod
by Jonathan (Curate) on May 03, 2000 at 12:26 UTC
    Who's version of Unix are you using. for example Solaris has access control lists (ACLS) that can override standard permissions