Index: trunk/tools/runcameraexp.pl
===================================================================
--- trunk/tools/runcameraexp.pl	(revision 29158)
+++ trunk/tools/runcameraexp.pl	(revision 29159)
@@ -32,5 +32,5 @@
 my $dbh = getDBHandle();
 
-my $query = "SELECT rawExp.camera, rawExp.exp_tag, camProcessedExp.path_base, camRun.dvodb, camRun.reduction, camRun.state FROM camRun JOIN camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE cam_id = $cam_id";
+my $query = "SELECT rawExp.camera, rawExp.exp_tag, camProcessedExp.path_base, camProcessedExp.fault, camRun.dvodb, camRun.reduction, camRun.state FROM camRun JOIN camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE cam_id = $cam_id";
 
 my $stmt = $dbh->prepare($query);
@@ -44,4 +44,5 @@
 my $reduction = $results->{reduction};
 my $state = $results->{state};
+my $fault = $results->{fault};
 
 die "path_base not found\n" if !$path_base;
@@ -51,4 +52,6 @@
 die "state not found\n" if !$state;
 die "reduction not found\n" if !$reduction;
+
+die "Cannot update when run is not faulted\n" if $update and ! $fault;
 
 my  $run_state;
@@ -63,8 +66,9 @@
 $command .= " --reduction $reduction" if $reduction and ($reduction ne "NULL");
 $command .= " --dvodb $dvodb" if $dvodb and ($dvodb ne "NULL");
-$command .= " --redirect-output" if $redirect;
+$command .= " --redirect-output" if $redirect or $update;
 $command .= " --no-update" unless $update;
 $command .= " --verbose" unless $no_verbose;
 $command .= " --dbname $dbname" if $dbname;
+
 
 
@@ -109,2 +113,50 @@
 }
 
+__END__
+
+=pod
+
+=head1 NAME
+
+runcameraexp.pl - gather the parameters for and execute camera_exp.pl
+
+=head1 SYNOPSIS
+    
+    perl runcameraexp.pl --cam_id <cam_id> [--update] [--redirect-output] [--pretend] [--dbname <dbname>]
+
+Query the database for the results of a completed camera run and rerun the processing, optionally reverting a faulted
+run.
+
+=over 4
+
+=item * --cam_id <cam_id>
+
+The id of the camera run to process.
+
+=item * --update
+
+Revert a faulted run before processing. WARNING: insure that the standard science procesing either has camera stage turned off or the
+label of this camRun ommited from the label list otherwise it may attempt to processes this run at the same time.
+Optional.
+
+=item *  --redirect-output
+
+Send the output of the command to the logfile. (This is the default if --update is supplied);
+Optional.
+
+=item * --pretend
+
+Just print the commands that would be executed, but do not run them.
+Optional.
+
+
+=item * --dbname <dbname>
+
+Name of the IPP databse to query. Default is 'gpc1'.
+Optional.
+
+
+=head1 SEE ALSO
+L<runchipimfile.pl>, L<runwarpskyfile.pl>, L<rundiffskyfile.pl>
+
+=cut
