01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
my $from = $ARGV[0] || usage(); my @path = split(/[:\/]/, $from); my $to = pop @path; unless (defined $to || -d "$DIR/$to") { print "mkdir \"$DIR/$to\"\n"; mkdir("$DIR/$to", 0400) || die "mkdir error: $!"; } unless (-x $RSYNC) { print "rsync command not executable: $RSYNC\n"; exit; } load_sshenv(); my @cmd = ($RSYNC, @RSYNC_ARGS, $from, "$DIR/$to"); print "@cmd\n"; system(@cmd); print " USAGE: $0 target\n"; print "\tplease specify target host or directory\n"; exit; open(F, $SSH_AGENT_ENV) || die "open error: $SSH_AGENT_ENV: $!"; while (my $line = <F>) { if ($line =~ /^setenv\s+(\S+)\s+(\S+);$/) { $ENV{$1} = $2; print $line; } } close F;