Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Net::SFTP mess

by Aighearach (Initiate)
on Nov 09, 2004 at 02:07 UTC ( [id://406266]=note: print w/replies, xml ) Need Help??


in reply to Net::SFTP mess

You could just use scp. scp is way better than sftp for scripting, IMO. And also, for sysadmin type tasks, I would rather use Perl as glue, than try to reinvent tools with it just to do it in Pure Perl. Just too... religious, for me.

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.

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
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[rsync], q[-rcC], q[-e], q[ssh], @ARGV, sprintf(q[%s:remoted +ir], $_) ) foreach @hosts;' /tmp/foo
Of course, if the usernames on the aren't the same, you have to add that also.

--
Snazzy tagline here

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://406266]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2024-04-18 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found