Index: trunk/ippScripts/scripts/phase2.pl
===================================================================
--- trunk/ippScripts/scripts/phase2.pl	(revision 11316)
+++ trunk/ippScripts/scripts/phase2.pl	(revision 11319)
@@ -26,6 +26,6 @@
 
 # Parse the command-line arguments
-my ($expTag,			# Exposure tag
-    $classId,			# Class Id
+my ($exp_tag,			# Exposure tag
+    $class_id,			# Class Id
     $input,			# Input FITS file
     $camera,			# Camera
@@ -35,6 +35,6 @@
     );
 GetOptions(
-    'exp_tag|e=s'   => \$expTag,
-    'class_id|i=s'  => \$classId,
+    'exp_tag|e=s'   => \$exp_tag,
+    'class_id|i=s'  => \$class_id,
     'uri|u=s'       => \$input,
     'camera|c=s'    => \$camera,
@@ -46,8 +46,8 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --exp_tag --class_id --uri --camera --outpath",
+    -msg => "Required options: --exp_tag --class_id --uri --camera --workdir",
     -exitval => 3,
-) unless defined $expTag 
-    and defined $classId 
+) unless defined $exp_tag 
+    and defined $class_id 
     and defined $input
     and defined $camera;
@@ -70,13 +70,13 @@
 
 ### Output file name --- must match camera configuration!
-my $outputRoot =  $expTag . '.p2';
+my $outputRoot =  $exp_tag . '.p2';
 $outputRoot = File::Spec->catfile( $workdir, $outputRoot );
 $outputRoot = $ipprc->convert_filename_absolute($outputRoot);
 $input = $ipprc->convert_filename_absolute ( $input );
 
-my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $classId);
-my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $classId);
-my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $classId);
-my $outputStats = $outputRoot  . '.' . $classId . '.stats';
+my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id);
+my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id);
+my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
+my $outputStats = $outputRoot  . '.' . $class_id . '.stats';
 
 # Run ppImage
@@ -91,5 +91,5 @@
 	run(command => $command, verbose => 1);
     unless ($success) {
-	$error_code >> 8;
+	$error_code = $error_code >> 8;
 	&my_die("Unable to perform ppImage: $error_code", $exp_tag, $class_id, $error_code);
     }
@@ -122,6 +122,6 @@
     # Command to run p2tool
     my $command = "$p2tool -addprocessedimfile";
-    $command .= " -exp_tag $expTag";
-    $command .= " -class_id $classId";
+    $command .= " -exp_tag $exp_tag";
+    $command .= " -class_id $class_id";
     $command .= " -recip " . RECIPE;
     $command .= " -uri $outputImage";
@@ -136,5 +136,5 @@
 	run(command => $command, verbose => 1);
     unless ($success) {
-	$error_code >> 8;
+	$error_code = $error_code >> 8;
 	warn("Unable to perform p2tool -addprocessedimfile: $error_code\n");
 	exit($error_code);
@@ -154,5 +154,5 @@
     warn($msg);
     if ($exp_tag and $class_id) {
-	my $command = "$dettool -addprocessedimfile -exp_tag $exp_tag -class_id $class_id -code $exit_code";
+	my $command = "$p2tool -addprocessedimfile -exp_tag $exp_tag -class_id $class_id -code $exit_code";
 	$command .= " -dbname $dbname" if defined $dbname;
         system ($command);
