Index: /trunk/ippScripts/scripts/inject.pl
===================================================================
--- /trunk/ippScripts/scripts/inject.pl	(revision 10362)
+++ /trunk/ippScripts/scripts/inject.pl	(revision 10363)
@@ -15,6 +15,4 @@
     $telescope,			# Telescope used
     $exp_type,			# Type of exposure
-    $class,			# Prefix for class id
-    $num,			# Number of imfiles
     $path,			# Path to use
     );
@@ -23,16 +21,13 @@
 	   'telescope|t=s' => \$telescope,
 	   'exp_type|e=s' => \$exp_type,
-	   'class_id=s' => \$class,
-	   'num|n=i' => \$num,
 	   'path=s' => \$path,
 ) or pod2usage( 2 );
 
 pod2usage(
-    -msg => "Required options: --camera --telescope --exp_type --num --path",
+    -msg => "Required options: --camera --telescope --exp_type --path",
     -exitval => 3,
 ) unless defined $camera
     and defined $telescope
     and defined $exp_type
-    and defined $num
     and defined $path;
 
@@ -48,8 +43,20 @@
 
 
+my @classes;
+my $imfiles;
+if ($camera eq "MEGACAM") {
+    for (my $i = 0; $i < 36; $i++) {
+	push @classes, sprintf("ccd%02d", $i);
+    }
+} elsif ($camera eq "MCSHORT") {
+    @classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' );
+} else {
+    die "Unrecognised camera name: $camera.\n";
+}
+
 # Inject new data into the database
 {
     foreach my $exp ( @ARGV ) {
-	my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -exp_type $exp_type -imfiles $num"; # Command to run
+	my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -exp_type $exp_type -imfiles " . scalar @classes; # Command to run
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run( command => $command, verbose => 1 );
@@ -58,15 +65,9 @@
 	my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag
 	my $exp_tag = $line[2];	# The exposure tag
-	for (my $i = 0; $i < $num; $i++) {
-	    my $class_id;
-	    if (defined $class) {
-		$class_id = sprintf $class, $i; # Name for class_id
-	    } else {
-		$class_id = $i;
-	    }
+	foreach my $class_id (@classes) {
 	    my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $path/$exp.$class_id.fits"; # Command to run
 	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 		run( command => $command, verbose => 1 );
-	    die "Unable to inject $exp $i: $error_code\n" if not $success;
+	    die "Unable to inject $exp $class_id: $error_code\n" if not $success;
 	}
     }
