in reply to Best way to write to a file owned by root?
but then started getting errors (root doesn't know where my personal perl library resides).
let me suggest a different direction to solve that
i have a file in /usr/bin called perlhuck. It is chmod ugo+x. it contains
where /home/huck/cvs/perl_site_lib2 is my personal perl library. Im very old school, for decades when i wanted to run a perl program id say perl <program>.pl, so it is very natural to say perlhuck <program>.pl too. Having this script around allows me to place this line into my cgi-bin programs as the first line.#!/bin/sh perl -I /home/huck/cvs/perl_site_lib2 "$@"
And they run just fine knowing where my personal libs are. I also place that as the first line of my chmod ugo+x perl programs. If i wanted to i could extend the path and do all sorts of other things in perlhuck too.#!/usr/bin/perlhuck
if you had such a script, say perlnysus then you could say sudo perlnysus <program>.pl and everything would still work fine.
So i suggest you create a perlnysus script, and either say sudo perlnysus <program>.pl or place #!/usr/bin/perlnysus into the first line of your executable perl programs and say sudo <program>.pl
|
|---|