in reply to Net::SFTP mess
I use public/private keys for authentication in this case, because not only is it (only slighter) safer than putting the password in the script, but it removes the need to interact with scp in order to transfer files.
Here is another version using ssh and rsync, so as to only send the parts that changed, and ignores .CVS files:perl -e '@hosts = ( map { $_ . q[.example.com] } qw/ foo bar www / ); +system( q[scp], q[-r], @ARGV, sprintf(q[%s:remotedir], $_) ) foreach +@hosts;' /tmp/foo
Of course, if the usernames on the aren't the same, you have to add that also.perl -e '@hosts = ( map { $_ . q[.example.com] } qw/ foo bar www / ); +system( q[rsync], q[-rcC], q[-e], q[ssh], @ARGV, sprintf(q[%s:remoted +ir], $_) ) foreach @hosts;' /tmp/foo
|
---|