Index: trunk/ippScripts/scripts/summit_copy.pl
===================================================================
--- trunk/ippScripts/scripts/summit_copy.pl	(revision 16641)
+++ trunk/ippScripts/scripts/summit_copy.pl	(revision 17652)
@@ -1,13 +1,6 @@
 #!/usr/bin/env perl
 
-use Carp;
 use warnings;
 use strict;
-
-## report the program and machine
-use Sys::Hostname;
-my $host = hostname();
-print "\n\n";
-print "Starting script $0 on $host\n\n";
 
 use vars qw( $VERSION );
@@ -15,60 +8,59 @@
 
 use IPC::Cmd 0.36 qw( can_run run );
+use PS::IPP::Config 1.01 qw( :standard );
 use PS::IPP::Metadata::Config;
 use PS::IPP::Metadata::Stats;
-
-use PS::IPP::Config qw($PS_EXIT_SUCCESS
-		       $PS_EXIT_UNKNOWN_ERROR
-		       $PS_EXIT_SYS_ERROR
-		       $PS_EXIT_CONFIG_ERROR
-		       $PS_EXIT_PROG_ERROR
-		       $PS_EXIT_DATA_ERROR
-		       $PS_EXIT_TIMEOUT_ERROR
-		       caturi
-		       );
-my $ipprc = PS::IPP::Config->new(); # IPP configuration
+use Sys::Hostname;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
 
+## report the program and machine
+my $host = hostname();
+print "\n\n";
+print "Starting script $0 on $host\n\n";
+
 # Parse the command-line arguments
 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $exp_name, $inst, $telescope, $class, $class_id, $end_stage, $workdir,
-     $dbname, $verbose, $no_update, $no_op );
+     $dbname, $verbose, $no_update, $no_op, $timeout );
 GetOptions(
-	   'uri=s'         => \$uri,       # source location of file on data store
-	   'filename=s'    => \$filename,  # target location of file on local system
-	   'compress'      => \$compress,  # request file in compressed format
-	   'bytes=s'       => \$bytes,     # reported file size in bytes
-	   'md5=s'         => \$md5,       # reported md5 checksum
-	   'nebulous'      => \$nebulous,  # use nebulous for the target file
-	   'exp_name=s'    => \$exp_name,  # Exposure name
-	   'inst=s'        => \$inst,      # Instrument
-	   'telescope=s'   => \$telescope, # Telescope
-	   'class=s'       => \$class,     # Class level
-	   'class_id=s'    => \$class_id,  # Class identifier
-	   'end_stage=s'   => \$end_stage, # end of processing
-	   'workdir=s'     => \$workdir,   # workdir
-	   'dbname=s'      => \$dbname,    # Database name
-	   'verbose'       => \$verbose,   # Print to stdout
-	   'no-update'     => \$no_update, # Don't update the database?
-	   'no-op'         => \$no_op,	   # Don't do any operations?
-	   ) or pod2usage( 2 );
+       'uri=s'          => \$uri,       # source location of file on data store
+       'filename=s'     => \$filename, # target location of file on local system
+       'compress'       => \$compress,  # request file in compressed format
+       'bytes=s'        => \$bytes,     # reported file size in bytes
+       'md5=s'          => \$md5,       # reported md5 checksum
+       'nebulous'       => \$nebulous,  # use nebulous for the target file
+       'exp_name=s'     => \$exp_name,  # Exposure name
+       'inst=s'         => \$inst,      # Instrument
+       'telescope=s'    => \$telescope, # Telescope
+       'class=s'        => \$class,     # Class level
+       'class_id=s'     => \$class_id,  # Class identifier
+       'end_stage=s'    => \$end_stage, # end of processing
+       'workdir=s'      => \$workdir,   # workdir
+       'dbname=s'       => \$dbname,    # Database name
+       'verbose'        => \$verbose,   # Print to stdout
+       'no-update'      => \$no_update, # Don't update the database?
+       'no-op'          => \$no_op,     # Don't do any operations?
+       'timeout|t'      => \$timeout,   # passed through to dsget
+) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage( -msg => "Required options: --uri --filename --exp_name --inst --telescope --class --class_id --workdir",
-	   -exitval => 3) unless
-    defined $uri and
-    defined $filename and
-    defined $exp_name and
-    defined $inst and
-    defined $telescope and
-    defined $class and
-    defined $class_id and
-    defined $workdir;
+       -exitval => 3)
+    unless defined $uri
+    and defined $filename
+    and defined $exp_name
+    and defined $inst
+    and defined $telescope
+    and defined $class
+    and defined $class_id
+    and defined $workdir;
 
 # Look for programs we need
 my $missing_tools;
-my $dsget = can_run('dsget') or (warn "Can't find dsget" and $missing_tools = 1);
-my $pztool = can_run('pztool') or (warn "Can't find pztool" and $missing_tools = 1);
+my $dsget = can_run('dsget')
+    or (warn "Can't find dsget" and $missing_tools = 1);
+my $pztool = can_run('pztool')
+    or (warn "Can't find pztool" and $missing_tools = 1);
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -76,19 +68,28 @@
 }
 
+# dsget command
 my $command;
-
-# dsget command
 $command  = "$dsget --uri $uri --filename $filename";
-$command .= " --compress"     if defined $compress;
-$command .= " --bytes $bytes" if defined $bytes;
-$command .= " --nebulous"     if defined $nebulous;
-$command .= " --md5 $md5"     if defined $md5;
+$command .= " --compress"           if defined $compress;
+$command .= " --bytes $bytes"       if defined $bytes;
+$command .= " --nebulous"           if defined $nebulous;
+$command .= " --md5 $md5"           if defined $md5;
+$command .= " --timeout $timeout"   if defined $timeout;
 
 # run command
 unless ($no_op) {
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
+        = run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform dsget: $error_code", $exp_name, $inst, $telescope, $class, $class_id, $uri, $error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        my_die("Unable to perform dsget: $error_code",
+            $exp_name,
+            $inst,
+            $telescope,
+            $class,
+            $class_id,
+            $uri,
+            $error_code
+        );
     }
 } else {
@@ -110,9 +111,10 @@
 # update the database
 unless ($no_update) {
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
+        = run(command => $command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	warn("Unable to perform $command: $error_code\n");
-	exit($error_code);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        warn("Unable to perform $command: $error_code\n");
+        exit($error_code);
     }
 } else {
@@ -131,29 +133,31 @@
     my $exit_code = shift; # Exit code to add
 
-    carp($msg);
+    warn $msg;
     unless ($no_update) {
-	# command to update database
-	my $command;
-	$command  = "$pztool -copydone";
-	$command .= " -exp_name $exp_name";
-	$command .= " -inst $inst";
-	$command .= " -telescope $telescope";
-	$command .= " -class $class";
-	$command .= " -class_id $class_id";
-	$command .= " -uri $uri";
-	$command .= " -code $exit_code";
-	$command .= " -dbname $dbname" if defined $dbname;
+        # command to update database
+        my $command;
+        $command  = "$pztool -copydone";
+        $command .= " -exp_name $exp_name";
+        $command .= " -inst $inst";
+        $command .= " -telescope $telescope";
+        $command .= " -class $class";
+        $command .= " -class_id $class_id";
+        $command .= " -uri $uri";
+        $command .= " -code $exit_code";
+        $command .= " -dbname $dbname" if defined $dbname;
 
         system ($command);
     }
+
     exit $exit_code;
 }
 
-END {
-    my $status = $?;
-    system("sync") == 0
-        or die "failed to execute sync: $!" ;
-    $? = $status;
-}
+# XXX: I don't think that we need this - JH
+#END {
+#    my $status = $?;
+#    system("sync") == 0
+#        or die "failed to execute sync: $!" ;
+#    $? = $status;
+#}
 
 __END__
