Index: trunk/ippScripts/scripts/inject.pl
===================================================================
--- trunk/ippScripts/scripts/inject.pl	(revision 11293)
+++ trunk/ippScripts/scripts/inject.pl	(revision 11345)
@@ -19,24 +19,25 @@
 
 # Parse the command-line arguments
-my ($outroot);
+my ($workdir, $dbname);
 GetOptions(
-    'outroot'     => \$outroot
+    'workdir|w=s'   => \$workdir,  # working directory for output files
+    'dbname|d=s'    => \$dbname    # Database name
 ) or pod2usage( 2 );
 
-pod2usage( -msg => "Usage: $0 [-outroot path] (files)", -exitval => 2 ) if scalar @ARGV == 0;
+pod2usage( -msg => "Usage: $0 [--workdir path] [--dbname dbname] (files)", -exitval => 2 ) if scalar @ARGV == 0;
 
 my $pxinject = can_run('pxinject') or die "Can't find pxinject\n";
 my $ppStats = can_run('ppStats') or die "Can't find ppStats\n";
 
-# if outroot is not defined, assign the current path
-if (! $outroot) {
-    $outroot = File::Spec->rel2abs( "." );
+# if workdir is not defined, assign the current path
+# XXX we need to handle relative paths for workdir (not allowed)
+if (! $workdir) {
+    $workdir = File::Spec->rel2abs( "." );
 }
-my $relroot = $ipprc->convert_filename_relative( $outroot );
 
 my $num = 0;
 foreach my $file ( @ARGV ) {
     my $absfile = File::Spec->rel2abs( $file );
-    inject($absfile, $relroot);
+    inject($absfile, $workdir, $dbname);
     $num ++;
 }
@@ -47,5 +48,6 @@
 {
     my $absfile = shift;		# absolute path for this file
-    my $outroot  = shift;		# absolute path for output directory
+    my $workdir  = shift;		# absolute path for output directory
+    my $dbname = shift;
 
     my ( $vol, $path, $name ) = File::Spec->splitpath( $absfile );
@@ -69,5 +71,8 @@
     }
     
-    my $command_exp = "$pxinject -newExp -exp_id $exp -inst $instrument -telescope $telescope -imfiles 1 -workdir $outroot" ; # Command to run
+    my $command_exp = "$pxinject -newExp -exp_id $exp -inst $instrument -telescope $telescope -imfiles 1 -workdir $workdir" ; # Command to run
+    if ($dbname) {
+	$command_exp = "$command_exp -dbname $dbname";
+    }
 
     my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) =
@@ -79,4 +84,7 @@
     
     my $command_imfile = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -uri $relfile"; # Command to run
+    if ($dbname) {
+	$command_imfile = "$command_imfile -dbname $dbname";
+    }
     
     my ( $success_imfile, $error_code_imfile, $full_buf_imfile, $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 );
