Re: ssh into remote nodes, do mulitple commands
- From: "J. Gleixner" <glex_no-spam@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 10:12:08 -0600
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.
.
- References:
- ssh into remote nodes, do mulitple commands
- From: Nene
- ssh into remote nodes, do mulitple commands
- Prev by Date: Re: "negative" regexp
- Next by Date: Re: "negative" regexp
- Previous by thread: Re: ssh into remote nodes, do mulitple commands
- Next by thread: List of directories within a directory
- Index(es):
Relevant Pages
|