Index: trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/stack_skycell.pl	(revision 19118)
+++ trunk/ippScripts/scripts/stack_skycell.pl	(revision 19262)
@@ -3,4 +3,5 @@
 use warnings;
 use strict;
+use Carp;
 
 ## report the program and machine
@@ -26,9 +27,10 @@
 use Pod::Usage qw( pod2usage );
 
-my ($stack_id, $dbname, $outroot, $verbose, $no_update, $no_op, $save_temps);
+my ($stack_id, $dbname, $outroot, $debug, $verbose, $no_update, $no_op, $save_temps);
 GetOptions(
     'stack_id|d=s'      => \$stack_id, # Stack identifier
     'dbname|d=s'        => \$dbname, # Database name
     'outroot=s'         => \$outroot, # Output root name
+    'debug'             => \$debug,   # Print to stdout
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update, # Don't update the database?
@@ -76,4 +78,7 @@
     }
 
+    if (@$stdout_buf == 0) {
+        &my_die("No input skyfiles selected", $stack_id, $PS_EXIT_PROG_ERROR);
+    }
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
@@ -115,6 +120,5 @@
 
 # Generate MDC file with the inputs
-my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.stk$stack_id.list.XXXX",
-                                      UNLINK => !$save_temps );
+my ($listFile, $listName) = tempfile( "/tmp/$tess_id.$skycell_id.stk.$stack_id.list.XXXX", UNLINK => !$save_temps );
 my $num = 0;
 my $inputSources;               # Sources to use as stamps
@@ -170,4 +174,5 @@
     $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
     $command .= " -photometry";
+    $command .= " -debug-stack" if defined $debug;
     $command .= " -tracedest $traceDest -log $logDest";
     $command .= " -dbname $dbname" if defined $dbname;
@@ -237,5 +242,5 @@
     my $exit_code = shift;      # Exit code to add
 
-    warn($msg);
+    carp($msg);
     if (defined $stack_id and not $no_update) {
         my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code";
