Index: trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/stack_skycell.pl	(revision 13275)
+++ trunk/ippScripts/scripts/stack_skycell.pl	(revision 13612)
@@ -18,4 +18,5 @@
 use PS::IPP::Metadata::List qw( parse_md_list );
 use Data::Dumper;
+use File::Temp qw( tempfile );
 
 use PS::IPP::Config qw($PS_EXIT_SUCCESS
@@ -51,5 +52,5 @@
 my $missing_tools;
 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
-my $ppStac = can_run('ppStac') or (warn "Can't find ppStac" and $missing_tools = 1);
+my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
 if ($missing_tools) { 
     warn("Can't find required tools.");
@@ -79,11 +80,9 @@
     scalar @$files >= 2;
 
-# Parse the list of input files, and get the skycell identifier
-my $inputList;			# List of input files
+# Parse the list of input files to get the tesselation, skycell identifiers and camera
 my $skycell_id;			# Skycell identifier
 my $tess_id;			# Tesselation identifier
 my $camera;			# Camera
 foreach my $file (@$files) {
-    $inputList .= $file->{uri} . ' ';
     if (defined $tess_id) {
 	&my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless
@@ -107,4 +106,21 @@
 &my_die("Can't find camera", $stack_id, $PS_EXIT_SYS_ERROR) unless $camera;
 $ipprc->define_camera($camera);
+
+# Generate MDC file with the inputs
+my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.stk$stack_id.list.XXXX", UNLINK => 1 );
+my $num = 0;
+foreach my $file (@$files) {
+    print $listFile "INPUT$num\tMETADATA\n";
+    $num++;
+    print $listFile "\tIMAGE\tSTR\t" . $file->{uri} . "\n";
+
+    ### XXX NEED TO UPDATE THESE appropriately
+    print $listFile "\tMASK\tSTR\t" . "NULL" . "\n"; 
+    print $listFile "\tSEEING\tF32\t" . 1.0 . "\n";
+    print $listFile "\tWEIGHT\tF32\t" . 1.0 . "\n";
+    print $listFile "\tSCALE\tF32\t" . 1.0 . "\n";
+
+    print $listFile "END\n\n";
+}
 
 # Get the output filenames
@@ -119,5 +135,5 @@
 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
 unless ($no_op) {
-    my $command = "$ppStac $outputName $inputList"; # Command to run pois
+    my $command = "$ppStack $listName $outputName -stat $outputStats"; # Command to run pois
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -130,16 +146,14 @@
 #    &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);
 #    &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);
-#    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
-
-    # Get the statistics on the residual image
-    if (0) { ### Disabled because ppStac doesn't output stats yet
-	my $statsFile;		# File handle
-	open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
-	my @contents = <$statsFile>; # Contents of file
-	close $statsFile;
-	my $metadata = $mdcParser->parse(join "", @contents) or
-	    &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
-	$stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
-    }
+    &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
+
+    # Get the statistics on the stacked image
+    my $statsFile;		# File handle
+    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
+    my @contents = <$statsFile>; # Contents of file
+    close $statsFile;
+    my $metadata = $mdcParser->parse(join "", @contents) or
+	&my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
+    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
 }
 
