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

require "libexec/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
