#!/usr/bin/perl -w # # pbsdcp -- Distributed copy command for the PBS environment # Copyright 2006 Ohio Supercomputer Center # # License: GNU GPL v2; see ../COPYING for details. # Revision info: # $HeadURL$ # $Revision$ # $Date$ # # Usage: pbsdcp [-g|-s] [options] srcfile [...srcfiles...] target # # Options: # -g gather mode # -s scatter mode (default) # # -h print a help message # -p preserve modification times and permissions # -r recursive copy if ( ! $ENV{"PBS_ENVIRONMENT"} || ( $ENV{"PBS_ENVIRONMENT"} ne "PBS_BATCH" && $ENV{"PBS_ENVIRONMENT"} ne "PBS_INTERACTIVE" ) || $ARGV[0] eq "-h" || $#ARGV < 1 ) { if ( ! $ENV{"PBS_ENVIRONMENT"} || ( $ENV{"PBS_ENVIRONMENT"} ne "PBS_BATCH" && $ENV{"PBS_ENVIRONMENT"} ne "PBS_INTERACTIVE" ) ) { warn "$0: Not running withing a PBS job, exiting.\n\n"; } print <; chop(@node); if ( $#node>0 ) { for ( $i=0 ; $i<=$#node; $i++ ) { if ( ($pid[$i]=fork)==0 ) { exec("rcp @ARGV $node[$i]:$target\n"); } } for ( $i=0 ; $i<=$#node; $i++ ) { waitpid($pid[$i],0); } } else { exec("cp @ARGV $target"); } } else { exec("cp @ARGV $target"); } } }