I have code as follows
 def initialise
   @doc_path =nil
   @user= nil
end
def execute
   oscmd = Common::OsCmd.new
   oscmd.log = @log.info("message")
   File.open("#{@doc_path}/new.doc","w") do |f|
      f.puts "/#{@name}  /people/* "
      File.chmod(0777,"#{@doc_path}/new.doc")
      FileUtils.chown("#{@user}, #{@user}, #{@doc_path}")
   end
end
So my code gets executed by tokenisation from other config file where it has values for doc_path, user
My code is giving error on chown and chmod
Try the below by passing valid user in chown :
def self.execute
   oscmd = Common::OsCmd.new
   oscmd.log = @log.info("message")
   File.open("#{@doc_path}/new.doc","w") do |f|
      f.puts "/#{@name}  /people/* "
      File.chmod(0777,"#{@doc_path}/new.doc")
      FileUtils.chown 'vinod', 'vinod', "#{@doc_path}" 
   end #-- do ends here
end #-- def ends here
chown usage:
http://apidock.com/ruby/FileUtils/chown
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With