Index: /trunk/ippScripts/scripts/ipp_serial_phase0.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_serial_phase0.pl	(revision 11845)
+++ /trunk/ippScripts/scripts/ipp_serial_phase0.pl	(revision 11846)
@@ -12,8 +12,10 @@
 use Pod::Usage qw( pod2usage );
 
-my ($dbname			# Database name to use
+my ($dbname,			# Database name to use
+    $workdir,			# Working directory
     );
 GetOptions(
-	   'dbname|d=s' => \$dbname,
+	   'dbname|d=s'  => \$dbname,
+	   'workdir|w=s' => \$workdir,
 ) or pod2usage( 2 );
 
@@ -50,4 +52,5 @@
     
     my $command = "$phase0_imfile --exp_tag $exp_tag --class $class --class_id $class_id --uri $uri --dbname $dbname";
+    $command .= " --workdir $workdir" if defined $workdir;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run( command => $command, verbose => 1 );
@@ -69,4 +72,5 @@
     
     my $command = "$phase0_exp --exp_tag $exp_tag --dbname $dbname";
+    $command .= " --workdir $workdir" if defined $workdir;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run( command => $command, verbose => 1 );
Index: /trunk/ippScripts/scripts/ipp_serial_phase2.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_serial_phase2.pl	(revision 11846)
+++ /trunk/ippScripts/scripts/ipp_serial_phase2.pl	(revision 11846)
@@ -0,0 +1,69 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use IPC::Cmd qw( can_run run );
+use PS::IPP::Metadata::Config;
+use PS::IPP::Metadata::List qw( parse_md_list );
+use Data::Dumper;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+
+my ($dbname,			# Database name to use
+    $workdir,			# Working directory
+    );
+GetOptions(
+	   'dbname|d=s' => \$dbname,
+	   'workdir|w=s' => \$workdir,
+) or pod2usage( 2 );
+
+pod2usage(
+	  -msg => "Required options: --dbname",
+	  -exitval => 3,
+	  ) unless defined $dbname;
+
+my $mdcParser = PS::IPP::Metadata::Config->new;	# Metadata config parser
+
+# Look for programs we need
+my $missing_tools;
+my $p2tool = can_run('p2tool') or (warn "Can't find p2tool" and $missing_tools = 1);
+my $phase2 = can_run('phase2.pl') or (warn "Can't find phase2.pl" and $missing_tools = 1);
+die "Can't find required tools.\n" if $missing_tools;
+
+# Phase 2 imfile processing
+my $list;
+{
+    my $command = "$p2tool -pendingimfile -dbname $dbname"; # Command to run
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run( command => $command, verbose => 1 );
+    die "Unable to get phase 2 imfile list: $error_code\n" if not $success;
+    $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or
+	die "Unable to parse output from p2tool.\n";
+}
+
+foreach my $item (@$list) {
+    my $exp_tag = $item->{exp_tag};
+    my $camera = $item->{camera};
+    my $class_id = $item->{class_id};
+    my $uri = $item->{uri};
+    
+    my $command = "$phase2 --exp_tag $exp_tag --class_id $class_id --uri $uri --dbname $dbname --camera $camera";
+    $command .= " --workdir $workdir" if defined $workdir;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run( command => $command, verbose => 1 );
+    die "Unable to do phase 2 processing on $exp_tag $class_id: $error_code\n" if not $success;
+}
+
+END {
+    my $status = $?;
+    system("sync") == 0
+        or die "failed to execute sync: $!" ;
+    $? = $status;
+}
+
+
+__END__
+
+
Index: /trunk/ippScripts/scripts/ipp_serial_phase3.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_serial_phase3.pl	(revision 11846)
+++ /trunk/ippScripts/scripts/ipp_serial_phase3.pl	(revision 11846)
@@ -0,0 +1,67 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use IPC::Cmd qw( can_run run );
+use PS::IPP::Metadata::Config;
+use PS::IPP::Metadata::List qw( parse_md_list );
+use Data::Dumper;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+
+my ($dbname,			# Database name to use
+    $workdir,			# Working directory
+    );
+GetOptions(
+	   'dbname|d=s' => \$dbname,
+	   'workdir|w=s' => \$workdir,
+) or pod2usage( 2 );
+
+pod2usage(
+	  -msg => "Required options: --dbname",
+	  -exitval => 3,
+	  ) unless defined $dbname;
+
+my $mdcParser = PS::IPP::Metadata::Config->new;	# Metadata config parser
+
+# Look for programs we need
+my $missing_tools;
+my $p3tool = can_run('p3tool') or (warn "Can't find p3tool" and $missing_tools = 1);
+my $phase3 = can_run('phase3.pl') or (warn "Can't find phase3.pl" and $missing_tools = 1);
+die "Can't find required tools.\n" if $missing_tools;
+
+# Phase 3 exposure processing
+my $list;
+{
+    my $command = "$p3tool -pendingexp -dbname $dbname"; # Command to run
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run( command => $command, verbose => 1 );
+    die "Unable to get phase 3 imfile list: $error_code\n" if not $success;
+    $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or
+	die "Unable to parse output from p2tool.\n";
+}
+
+foreach my $item (@$list) {
+    my $exp_tag = $item->{exp_tag};
+    my $camera = $item->{camera};
+    
+    my $command = "$phase3 --exp_tag $exp_tag --camera $camera";
+    $command .= " --workdir $workdir" if defined $workdir;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	run( command => $command, verbose => 1 );
+    die "Unable to do phase 3 processing on $exp_tag: $error_code\n" if not $success;
+}
+
+END {
+    my $status = $?;
+    system("sync") == 0
+        or die "failed to execute sync: $!" ;
+    $? = $status;
+}
+
+
+__END__
+
+
