It sounds like you have ruby on both ends? If so one solution would be to use webrick, a pure ruby web server that is in ruby's standard library. You can get more info here: http://www.webrick.org/. Here is an example of how easy it is to create a simple http server:
Code:
#!/usr/local/bin/ruby
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2000,
:DocumentRoot => Dir::pwd + "/htdocs"
)
## mount subdirectory
s.mount("/~username",
HTTPServlet::FileHandler, "/home/username/public_html",
true) #<= allow to show directory index.
trap("INT"){ s.shutdown }
s.start
This way you could run a webrick server on each computer and transfer files easily with curl or a web brower. Or if you want to keep it pure ruby use open-uri for the client side of the transfers. Here is an example of open-uri:
Code:
require 'open-uri'
remote_file = open("ip_address_of_server:2000/test.tar.gz").read
File.open("test.tar.gz", "w+") do |file|
file.write(remote_file)
end
And then if you want to flesh things out a bit, the webrick servelet will give a directory listing if you don't specify a file. You could have you client get a listing of available files and ask them on the command line for the name of the file they want. Then use that filename fo rhte open-uri request and the file.write and you would have a pretty cool system~
-Ezra
Bookmarks