Index: trunk/ippScripts/scripts/ipp_serial_chip.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 15481)
+++ trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 16336)
@@ -13,17 +13,23 @@
 
 my ($dbname,			# Database name to use
+    $workdir_default,		# Default working directory
+    $verbose,			# Verbose operations?
     $no_op,			# No operations?
     $no_update,			# No updating?
     );
 GetOptions(
-	   'dbname|d=s' => \$dbname,
+	   'dbname=s' => \$dbname,
+	   'workdir=s' => \$workdir_default,
+	   'verbose' => \$verbose,
 	   'no-op' => \$no_op,
 	   'no-update' => \$no_update,
 ) or pod2usage( 2 );
 
-pod2usage(
-	  -msg => "Required options: --dbname",
-	  -exitval => 3,
-	  ) unless defined $dbname;
+pod2usage( -msg => "Required options: --dbname --workdir",
+	   -exitval => 3,
+	   ) unless
+    defined $dbname;
+
+$workdir_default = `pwd` unless defined $workdir_default;
 
 my $mdcParser = PS::IPP::Metadata::Config->new;	# Metadata config parser
@@ -35,5 +41,5 @@
 die "Can't find required tools.\n" if $missing_tools;
 
-# Phase 2 imfile processing
+# Imfile processing
 my @whole;			# The whole list for processing
 {
@@ -65,10 +71,13 @@
 	    my $reduction = $item->{reduction};
 	    my $workdir = $item->{workdir};
-	    
-	    my $command = "$chip --chip_id $chip_id --exp_id $exp_id --exp_tag $exp_tag --class_id $class_id --uri $uri --dbname $dbname --camera $camera";
+	    $workdir = $workdir_default unless (defined $workdir or $workdir ne "NULL");
+
+	    my $outroot = $workdir . '/' . ${exp_tag} . '/' . ${exp_tag} . '.ch.' . ${chip_id};
+
+	    my $command = "$chip --chip_id $chip_id --exp_id $exp_id --exp_tag $exp_tag --class_id $class_id --uri $uri --dbname $dbname --camera $camera --outroot $outroot";
 	    $command .= " --reduction $reduction" if defined $reduction;
+	    $command .= " --verbose" if defined $verbose;
 	    $command .= " --no-op" if defined $no_op;
 	    $command .= " --no-update" if defined $no_update;
-	    $command .= " --workdir $workdir" if defined $workdir and $workdir ne "NULL";
 	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 		run( command => $command, verbose => 1 );
