Index: trunk/ippScripts/scripts/publish_file.pl
===================================================================
--- trunk/ippScripts/scripts/publish_file.pl	(revision 30376)
+++ trunk/ippScripts/scripts/publish_file.pl	(revision 34475)
@@ -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(
@@ -62,4 +63,5 @@
     'redirect-output'   => \$redirect,   # Redirect output to log file?
     'output_format=i'   => \$output_format, # Output format for ppMops
+    'difftype=s'        => \$difftype,    # "WW" / "WS" / "SW"
     ) or pod2usage( 2 );
 
@@ -195,4 +197,29 @@
         $filename = $resolved;
 
+	my $cam_id = $comp->{cam_id_1};
+	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};
+	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];
+
         my $data = { zp => $zp,
                      zp_err => $comp->{zpt_stdev},
@@ -207,4 +234,9 @@
                      output_format => $comp->{output_format},
                      direction => 1,
+		     comment => $reg_comp->{comment},
+		     obsmode => $reg_comp->{obs_mode},
+		     difftype => $difftype,
+		     sky => $cam_comp->{bg},
+		     shutoutc => $comp->{dateobs},
         };
 
@@ -239,4 +271,9 @@
                          diff_id => $comp->{diff_id},
                          direction => 0,
+			 comment => $reg_comp->{comment},
+			 obsmode => $reg_comp->{obs_mode},
+			 difftype => $difftype,
+			 sky => $cam_comp->{bg},
+			 shutoutc => $comp->{dateobs},
             };
 
@@ -288,6 +325,4 @@
     &my_die( "Unable to register with data store", $pub_id, $PS_EXIT_SYS_ERROR) unless $success;
 }
-
-
 
 ### Pau.
@@ -311,4 +346,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 +363,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} != $data->{comment};
+    &my_die("obsmode value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{obsmode} and $comp->{obsmode} != $data->{obsmode};
+    &my_die("difftype value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{difftype} and $comp->{difftype} != $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} != $data->{shutoutc};
 
     return 1;
@@ -350,4 +395,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) {
