On Wed, Jan 29, 2014 at 2:10 PM, Martin G. McCormick <
mar...@server1.shellworld.net> wrote:

>         I have a perl script that I run as root which needs to
> move a file from where it is to another directory.
>
>         I keep getting the "Usage"  help message and a
> permission denied. If I su to root and manually make the move,
> it works.
>
>         The perl script is not trying to run suid to root. I am
> root when I call it. The line in question reads:
>
> system(
> "mv $directories$filename \"$directories\"deleted_keys/"
> );
>
> $directories and $filename are correctly set at the time. The
> output from the script is:
>
> usage: mv [-f | -i | -n] [-v] source target
>        mv [-f | -i | -n] [-v] source ... directory
> /var/named/etc/namedb/dynamic/okstate.edu/deleted_keys/: Permission denied
>
> As I said, it works if I become root and manually move the file
> in question.o
> This is basically a script for moving expired dnssec keys out of
> the directory and in to a morgue of dead keys which we will keep
> around if there is trouble-shooting to be done later.
>
> The script, when run, is owned by root and run by root
>



Another recommendation:

File::Copy is core now I believe, is portable, faster, easier and more
transparent  than deciphering shell error returns, and enables you
to avoid the nasty quoting issues of a 'system' call:

use File::Copy;
move( $file1, $file2) or die "move: $!";

See: perldoc File::Copy

-- 
Charles DeRykus

Reply via email to