tags:

views:

41

answers:

1

I'm running into a rather odd problem with Ruby and File.chmod (same problem exists with FileUtils.chmod.

Here is what I am doing for a test case:

File.chmod(1777, "testfile")

But once I have done that, I get this as a permission set:

--wxrwS--t

This problem only exists when using the *nix 4 digit permission sets. I googled it, but didn't get anything of value. When the permission set is 0777 it assigns properly, but anything higher than 0 for the first digit will mess up the permissions pretty bad.

Anybody have any tips?

I know I could make a system call to do what I want, but I'm sure it is something simple that I'm missing.

+3  A: 

01777 will work. In ruby a leading zero in an integer literal specifies that it's written in octal notation and file permissions are usually written as octal numbers.

sepp2k
This is why I love stackoverflow. 5 minutes and I have my answer. Thanks!
Eugene