Index: trunk/DataChallenge/inject_essence.pl
===================================================================
--- trunk/DataChallenge/inject_essence.pl	(revision 10596)
+++ trunk/DataChallenge/inject_essence.pl	(revision 10601)
@@ -40,20 +40,18 @@
 	my $relpath = $ipprc->convert_filename_relative( $file );
 
-	{
-	    my $command = "$pxinject -newExp -exp_id $exp -inst CTIO_MOSAIC2 -telescope CTIO4m " .
-		"-exp_type $type -imfiles 1" ; # Command to run
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run( command => $command, verbose => 1 );
-	    die "Unable to inject $exp: $error_code\n" if not $success;
-	}
+	my $command_exp = "$pxinject -newExp -exp_id $exp -inst CTIO_MOSAIC2 -telescope CTIO4m " .
+	    "-exp_type $type -imfiles 1" ; # Command to run
+	my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) =
+	    run( command => $command_exp, verbose => 1 );
+	die "Unable to inject $exp: $error_code\n" if not $success_exp;
+	
+	my @line = split(/\s+/, $$stdout_buf_exp[0]); # The output line, containing the exposure tag
+	my $exp_tag = $line[2];	# The exposure tag
 
-	{
-	    my $command = "$pxinject -newImfile -exp_tag $exp -class fpa -class_id fpa " .
-		"-uri $relpath"; # Command to run
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		run( command => $command, verbose => 1 );
-	    die "Unable to inject $exp imfile: $error_code\n" if not $success;
-	}
-	
+	my $command_imfile = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa " .
+	    "-uri $relpath"; # Command to run
+	my ( $success_imfile, $error_code_imfile, $full_buf_imfile,
+	     $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 );
+	die "Unable to inject $exp imfile: $error_code\n" if not $success;
     }
 
