How to run File Operation as sudo

Hi

    f=File.new("/etc/fstab","a+")
    f.puts  entry

now problem is ,
I am running the script as not root user ,now its failing because the
user does not root priviligies

now how will do this ??

can i run that ruby module as sudo ??

thanks

sharmin malik wrote in post #1075694:

    f=File.new("/etc/fstab","a+")
    f.puts  entry

now problem is ,
I am running the script as not root user ,now its failing because the
user does not root priviligies

now how will do this ??

can i run that ruby module as sudo ??

Start your script using

sudo ruby myscript.rb

You can’t gain root privileges mid-script, short of

system("sudo ruby anotherscript.rb")