Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 33051)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 33052)
@@ -147,9 +147,10 @@
 my $outputBin2;
 my $dump_config = 1;
+my $do_stats = 1;
+$outputStats   = prepare_output("PPIMAGE.STATS",         $outroot, $class_id, 1);
 my $do_binned_images = 1;
 if ($run_state eq 'new') {
     # prepare the files that are only created for a new run
     $configuration = prepare_output("PPIMAGE.CONFIG",        $outroot, $class_id, 1);
-    $outputStats   = prepare_output("PPIMAGE.STATS",         $outroot, $class_id, 1);
 } else {
     $configuration = $ipprc->filename('PPIMAGE.CONFIG', $outroot, $class_id) 
@@ -196,5 +197,4 @@
 unless ($no_op) {
     my $command;
-    my $do_stats;
 
     ## get the ppImage recipe for this camera and CHIP reduction
@@ -470,5 +470,5 @@
         $command .= " -Db PPIMAGE:PHOTOM FALSE";
     }
-    if ($run_state eq "new") {
+    if ($run_state eq "new" or $do_stats) {
         $command .= " -recipe PPSTATS CHIPSTATS";
         $command .= " -stats $outputStats";
@@ -562,14 +562,23 @@
 
 # Add the processed file to the database
-unless ($no_update) {
-    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 chiptool -addprocessedimfile: $error_code\n");
-        exit($error_code);
-    }
-} else {
-    print "skipping command: $command\n";
+my $tries = 0;
+while (1) {
+    $tries++;
+    unless ($no_update) {
+        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 chiptool -addprocessedimfile: $error_code\n");
+            exit($error_code) if $tries >= 3;
+            warn("Waiting 10 seconds to try again\n");
+            sleep 10;
+        } else {
+            last;
+        }
+    } else {
+        print "skipping command: $command\n";
+        last;
+    }
 }
 
