From: Rob Biedenharn Date: 2009-10-10T05:46:50+09:00 Subject: Re: File.addmod? On Oct 9, 2009, at 3:29 PM, Roger Pack wrote: > I'm familiar with > File.chmod 0777 filename > > however, anybody know the equivalent to "chmod u+r filename" from the > command line--but in ruby? > Thanks! > -r > -- > Posted via http://www.ruby-forum.com/. > File.class_eval do def self.addmod(flags, filename) themode=stat(filename).mode | flags chmod(themode, filename) end end Although there's no error checking and the return value could probably be something better (like themode). So after defining that, your 'u+r' would be: File.addmod(0200, 'filename') -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com