如何将文件从一台服务器复制到另一台服务器? [英] How do I copy a file from one server to another?
本文介绍了如何将文件从一台服务器复制到另一台服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一台只有 xls 日志文件的服务器.每个文件为 5-15Mb,并且在任何时间点添加文件的意义上它都是动态的.现在我需要一种方法来使用 Ruby 执行以下过程.
I have one server which has nothing but xls log files. Each file is 5-15Mb and it is dynamic in the sense that files get added at any point of time. Now I need a way to do the following process using Ruby.
- 通过将文件名从只有日志文件的一台服务器发送到另一台服务器来复制文件.
- 我需要将服务器密码作为参数传递.
- 一切都在后台发生,由 Ruby 脚本触发.
推荐答案
这就是它的工作原理
我使用了 net-ssh &@theTinMan 建议的 net-scp gem 并且我能够复制我的文件.
I used the net-ssh & net-scp gem as suggested by @theTinMan and i was able to copy my files.
require 'rubygems'
require 'net/ssh'
require 'net/scp'
Net::SSH.start("ip_address", "username",:password => "*********") do |session|
session.scp.download! "/home/logfiles/2-1-2012/login.xls", "/home/anil/Downloads"
end
并复制整个文件夹
require 'rubygems'
require 'net/ssh'
require 'net/scp'
Net::SSH.start("ip_address", "username",:password => "*********") do |session|
session.scp.download!("/home/logfiles/2-1-2012", "/home/anil/Downloads", :recursive => true)
end
这篇关于如何将文件从一台服务器复制到另一台服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文