#!/usr/bin/env ruby
#
# dcast-cp $Revision: 0.01 $
#
# Copyright (C) 2006, Masahiro Nakao <mnakao@pre-dawn.net>
# You can redistribute it and/or modify it under GPL2 or more.

require "nodes_class"

#############################
# HELPå
#############################
if ARGV[0] == "--help" || ARGV[0] == "-h"
  puts "Usage: dcast-cp f1 f2; or: dcast-cp [-rp] f1 ... fn directory"
  exit 0
end

#############################
# ץβ
#############################
if ARGV.length == 0 || ARGV.length == 1
  puts "ʤޤ"
  exit 1
end

str = ""
last_argv = ARGV.pop

ARGV.each{|s|
  str = str + " " + s
}
str = str.sub(/\ /,"")

#############################
# main
#############################
begin
  slave = Nodes.new("slave")
 
  slave.name.each{|name|
    puts "rcp " + str + " " + name + ":" + last_argv
    system("rcp " + str + " " + name + ":" + last_argv)
  }
end
