Index: trunk/pstamp/scripts/pstamp_job_run.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_job_run.pl	(revision 18234)
+++ trunk/pstamp/scripts/pstamp_job_run.pl	(revision 18235)
@@ -9,17 +9,27 @@
 use strict;
 
-if (@ARGV != 1) {
-    die "usage: $0 job_id\n";
+use Sys::Hostname;
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+
+my $verbose;
+my $dbname;
+my $job_id;
+
+my $host = hostname();
+
+
+GetOptions(
+    'job_id=s'  =>  \$job_id,
+    'dbname=s'  =>  \$dbname,
+    'verbose'   =>  \$verbose,
+);
+
+
+if ($verbose) {
+    print "\n\n";
+    print "Starting script $0 on $host\n\n";
 }
 
-my $job_id = $ARGV[0];
-
-my $verbosity = 1;
-
-use Sys::Hostname;
-my $host = hostname();
-
-print "\n\n";
-print "Starting script $0 on $host\n\n";
+die "job_id is required" if !$job_id;
 
 use IPC::Cmd 0.36 qw( can_run run );
@@ -58,6 +68,7 @@
 {
     my $command = "$pstamptool -pendingjob -job_id $job_id";
+    $command .= " -dbname $dbname" if $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
         die("Unable to perform pstamptool -pendingjob: $error_code");
@@ -89,6 +100,7 @@
 if ($jobType eq "stamp") {
     my $command = "$ppstamp -file $uri $outputBase $argString";
+    $command .= " -dbname $dbname" if $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
+        run(command => $command, verbose => $verbose);
 
     if ($success) {
@@ -100,6 +112,7 @@
 } elsif ($jobType eq "get_image") {
     my $command = "$pstamp_get_image_job --uri $uri --out_dir $outputBase";
+    $command .= " -dbname $dbname" if $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
+        run(command => $command, verbose => $verbose);
 
     if ($success) {
@@ -117,6 +130,7 @@
 {
     my $command = "$pstamptool -processedjob -job_id $job_id -state stop -result $jobStatus";
+    $command .= " -dbname $dbname" if $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
+        run(command => $command, verbose => $verbose);
     unless ($success) {
         die("Unable to perform $command: $error_code");
