Index: branches/eam_branches/ipp-20120905/ippScripts/scripts/ipp_apply_burntool_single.pl
===================================================================
--- branches/eam_branches/ipp-20120905/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 34466)
+++ branches/eam_branches/ipp-20120905/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 34566)
@@ -241,5 +241,5 @@
     $status = vsystem ($command, $REALRUN);
     if ($status) {
-	&my_die("failed to update imfile");
+	&my_die("failed to update imfile",$exp_id,$class_id);
     }
 
@@ -274,4 +274,5 @@
         my $exp_id = shift;
         my $class_id = shift;
+	sleep(5); # Take a quick nap to let the database cool down, in case we failed doing an update.
         vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state 0 -set_state pending_burntool",1);
     }
Index: branches/eam_branches/ipp-20120905/ippScripts/scripts/publish_file.pl
===================================================================
--- branches/eam_branches/ipp-20120905/ippScripts/scripts/publish_file.pl	(revision 34466)
+++ branches/eam_branches/ipp-20120905/ippScripts/scripts/publish_file.pl	(revision 34566)
@@ -32,4 +32,5 @@
 my $pubtool = can_run('pubtool') or (warn "Can't find pubtool" and $missing_tools = 1);
 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
+my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);
 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
 my $ppMops = can_run('ppMops') or (warn "Can't find ppMops" and $missing_tools = 1);
@@ -44,5 +45,5 @@
 my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir, $need_magic );
 my ( $dbname, $verbose, $no_update, $no_op, $save_temps, $redirect );
-my ( $output_format );
+my ( $output_format, $difftype );
 
 GetOptions(
@@ -72,5 +73,6 @@
     defined $stage and
     defined $stage_id and
-    defined $workdir;
+    defined $workdir and
+    defined $dbname;
 
 my $outroot = "$workdir/$product.$pub_id"; # Output root name
@@ -166,5 +168,5 @@
     my %negative;               # Data for negative diff detections
     foreach my $comp ( @$components ) {
-        my $path_base = $comp->{path_base}; # Base name for file
+	my $path_base = $comp->{path_base}; # Base name for file
         if (!$need_magic and $comp->{magicked}) {
             # This client is authorized to receive uncensored detections
@@ -194,4 +196,45 @@
 
         $filename = $resolved;
+
+	my $cam_id = $comp->{cam_id_1};
+	#print "Getting info from camera stage $cam_id\n";
+	my $cam_command =  "$camtool -processedexp -cam_id $cam_id";
+	$cam_command .= " -dbname $dbname" if defined $dbname;
+	my ( $cam_success, $cam_error_code, $cam_full_buf, $cam_stdout_buf, $cam_stderr_buf ) =
+	    run(command => $cam_command, verbose => $verbose);
+	&my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $cam_success;
+	my $cam_metadata = $mdcParser->parse(join "", @$cam_stdout_buf) or
+	    &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
+	my $cam_components = parse_md_list($cam_metadata) or
+	    &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
+	&my_die("More than one entry for cam_id $stage_id", $pub_id, $PS_EXIT_PROG_ERROR) if scalar @$cam_components > 1;
+	my $cam_comp = $$cam_components[0];
+
+	my $exp_id = $comp->{exp_id_1};
+	#print "Getting info from raw stage $exp_id\n";
+	my $reg_command =  "$regtool -processedimfile -exp_id $exp_id";
+	$reg_command .= " -dbname $dbname" if defined $dbname;
+	my ( $reg_success, $reg_error_code, $reg_full_buf, $reg_stdout_buf, $reg_stderr_buf ) =
+	    run(command => $reg_command, verbose => $verbose);
+	&my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $reg_success;
+	my $reg_metadata = $mdcParser->parse(join "", @$reg_stdout_buf) or
+	    &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
+	my $reg_components = parse_md_list($reg_metadata) or
+	    &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
+	my $reg_comp = $$reg_components[0];
+
+	# Now get the difftype value from diff->{diff_mode}
+	my $difftype = "";
+	if ($comp->{diff_mode} == 1) {
+	    $difftype = "WW";
+	} elsif ($comp->{diff_mode} == 2) {
+	    $difftype = "WS";
+	} elsif ($comp->{diff_mode} == 3) {
+	    $difftype = "SW"; # Not used yet
+	} elsif ($comp->{diff_mode} == 4) {
+	    $difftype = "SS";
+	} else {
+	    $difftype = "Unsupported diff_mode value: [" . $comp->{diff_mode} . "]";
+	}
 
         my $data = { zp => $zp,
@@ -207,6 +250,12 @@
                      output_format => $comp->{output_format},
                      direction => 1,
+		     comment => $reg_comp->{comment},
+		     obsmode => $reg_comp->{obs_mode},
+		     difftype => $difftype,
+		     sky => $cam_comp->{bg},
+		     shutoutc => $reg_comp->{dateobs},
         };
 
+	#warn("Checking for positive");
         diff_check(\%positive, $data, "positive");
 
@@ -239,6 +288,12 @@
                          diff_id => $comp->{diff_id},
                          direction => 0,
+			 comment => $reg_comp->{comment},
+			 obsmode => $reg_comp->{obs_mode},
+			 difftype => $difftype,
+			 sky => $cam_comp->{bg},
+			 shutoutc => $reg_comp->{dateobs},
             };
 
+	    #warn("Checking for negative");
             diff_check(\%negative, $data, "negative");
 
@@ -288,6 +343,4 @@
     &my_die( "Unable to register with data store", $pub_id, $PS_EXIT_SYS_ERROR) unless $success;
 }
-
-
 
 ### Pau.
@@ -311,4 +364,9 @@
     $data->{diff_id} = $comp->{diff_id} unless defined $data->{diff_id};
     $data->{direction} = $comp->{direction} unless defined $data->{direction};
+    $data->{comment} = $comp->{comment} unless defined $data->{comment};
+    $data->{obsmode} = $comp->{obsmode} unless defined $data->{obsmode};
+    $data->{difftype} = $comp->{difftype} unless defined $data->{difftype};
+    $data->{sky} = $comp->{sky} unless defined $data->{sky};
+    $data->{shutoutc} = $comp->{shutoutc} unless defined $data->{shutoutc};
 
     &my_die("zp value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{zp} and $comp->{zp} != $data->{zp};
@@ -323,4 +381,9 @@
     &my_die("diff_id value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{diff_id} and $comp->{diff_id} != $data->{diff_id};
     &my_die("direction value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{direction} and $comp->{direction} != $data->{direction};
+    &my_die("comment value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{comment} and $comp->{comment} ne $data->{comment};
+    &my_die("obsmode value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{obsmode} and $comp->{obsmode} ne $data->{obsmode};
+    &my_die("difftype value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{difftype} and $comp->{difftype} ne $data->{difftype};
+    &my_die("sky value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{sky} and $comp->{sky} != $data->{sky};
+    &my_die("shutoutc value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{shutoutc} and $comp->{shutoutc} ne $data->{shutoutc};
 
     return 1;
@@ -350,4 +413,9 @@
     $command .= " -astrom_rms " . $data->{astrom} if defined $data->{astrom};
     $command .= " -version " . $data->{output_format} if defined $data->{output_format};
+    $command .= " -comment \"" . $data->{comment} . "\"" if defined $data->{comment};
+    $command .= " -obsmode " . $data->{obsmode} if defined $data->{obsmode};
+    $command .= " -difftype " . $data->{difftype} if defined $data->{difftype};
+    $command .= " -sky " . $data->{sky} if defined $data->{sky};
+    $command .= " -shutoutc \"" . $data->{shutoutc} . "\"" if defined $data->{shutoutc};
 
     unless ($no_op) {
Index: branches/eam_branches/ipp-20120905/ippScripts/scripts/staticsky.pl
===================================================================
--- branches/eam_branches/ipp-20120905/ippScripts/scripts/staticsky.pl	(revision 34466)
+++ branches/eam_branches/ipp-20120905/ippScripts/scripts/staticsky.pl	(revision 34566)
@@ -302,9 +302,10 @@
             $mask   = $ipprc->filename("PPSTACK.UNCONV.MASK",     $path_base ); # Mask name
             $variance = $ipprc->filename("PPSTACK.UNCONV.VARIANCE", $path_base ); # Weight name
+            $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name
         } else {
             $image  = $ipprc->filename("PPSTACK.OUTPUT",          $path_base ); # Image name
             $mask   = $ipprc->filename("PPSTACK.OUTPUT.MASK",     $path_base ); # Mask name
             $variance = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name
-            $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Weight name
+            $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name
         }
 
