Sticky bit via pure ruby

In unix you can do:

chmod -v a+wt /tmp

To set the sticky bit.

But how can I do this via ruby?

Just a wild shot in the dark, but according to this (
http://en.wikipedia.org/wiki/Sticky_bit#Examples), the octal code is
1000
for the sticky bit in unix.

In Ruby’s documentation
(http://ruby-doc.org/core/classes/File.html#M000037)
File#chmod can set the octal bits for a file, which I would guess would
be
1xxx, where xxx is what you normally set your permissions to (644
usually).

-Nick K.

Marc H. [email protected] wrote:

In unix you can do:

chmod -v a+wt /tmp

To set the sticky bit.

But how can I do this via ruby?

FileUtils in 1.9.3 has this capability, previous versions did not:

~/ruby-1.9.3/bin/ruby -rfileutils -e “FileUtils.chmod(‘a+wt’, ‘/tmp’)”

Oh yes, makes a lot of sense.

I’ll use the octal mode.

Thanks!

Eric W. [email protected] wrote:

FileUtils in 1.9.3 has this capability, previous versions did not:

~/ruby-1.9.3/bin/ruby -rfileutils -e “FileUtils.chmod(‘a+wt’, ‘/tmp’)”

I meant “did not” meaning it didn’t understand “a+wt”, not that it
couldn’t set the octal mode of 01666.