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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.