|
Posted by J. Gleixner on January 31, 2008, 11:12 am
Please log in for more thread options Nene wrote:
> Hello,
>
> I'm trying to use Net::SSH to ssh into 3 nodes and move/copy files
> with File::Copy. For now, I scripted it to find files of a certain
> age and move them.
> The $cmd variable is working, but when I try to move the files, it
> errors with copy failed. Please critique or suggest a better way.
[...]
> sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!";
> print "Connected to $host\n";
>
> while (<READER>) {
>
> if ( $_ ) {
> use File::Copy;
>
> move("/tmp/rod","/tmp/nasty") or die "Copy failed: $!";
>
> }
You're 'use'ing File::Copy on the machine that's running the script, not
on the remote host. So your 'move' is trying to move those files on the
host machine, not $host.
Probably easiest to just do "mv /tmp/rod /tmp/nasty" in another sshopen2
or better would be to modify the find command to move the files as
part of the exec, instead of ls -lt -- which is sort of useless.
|