Index: /trunk/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 18546)
+++ /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 18547)
@@ -24,8 +24,12 @@
 my $verbose = 0;
 my $dbname;
+my $project;
+my $job_type;
 
 GetOptions(
-    'verbose'   =>  \$verbose,
-    'dbname=s'  =>  \$dbname,
+    'job_type=s'    =>  \$job_type,
+    'dbname=s'      =>  \$dbname,
+    'project=s'     => \$project,
+    'verbose'       => \$verbose,
 );
 
@@ -35,4 +39,11 @@
     print "\n\n";
     print "Starting script $0 on $host\n\n";
+}
+
+my $listMode;
+if ($job_type and ($job_type eq 'list_uri')) {
+    $listMode=1;
+} else  {
+    $listMode=0;
 }
 
@@ -58,5 +69,5 @@
 my $pstamprequest = can_run('pstamprequest')  or (warn "Can't find pstamprequest"  and $missing_tools = 1);
 my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
-my $pstampparse = can_run('pstampparse')  or (warn "Can't find pstampparse"  and $missing_tools = 1);
+my $pstampparse = can_run('pstampparse.pl')  or (warn "Can't find pstampparse.pl"  and $missing_tools = 1);
 my $pstampparser_run = can_run('pstamp_parser_run.pl')  or (warn "Can't find pstamp_parser_run.pl"  and $missing_tools = 1);
 
@@ -66,17 +77,12 @@
 }
 
-# if -list is used, it must be the first argument
-my $listMode;
-if ($ARGV[0] eq "-list_uri" ) {
-    $listMode=1;
-} else  {
-    $listMode=0;
-}
-
+# make a request file
 my $cur_dir = getcwd();
 my $request_name = "web" . get_webreq_num();
 my $request_file = "$cur_dir/$request_name.fits";
 {
-    my $command = "$pstamprequest -request_name $request_name $request_file @ARGV";
+    my $command = "$pstamprequest -req_name $request_name -project $project $request_file @ARGV";
+    $command .= " -$job_type" if $job_type;     # default job_type is stamp
+
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
@@ -92,7 +98,5 @@
     ### In list mode just parse the file print the output and we're done
     ###
-    ### XXX TODO: I shouldn't need this -mode list_uri since it's in the request file
-    my $command = "$pstampparse -mode list_uri $request_file";
-    $command .= " -dbname $dbname" if $dbname;
+    my $command = "$pstampparse --mode list_uri --file $request_file --dbname $dbname";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
@@ -101,8 +105,11 @@
         ### print "Matching Images:\n";
         print @$stdout_buf;
+        exit 0;
     } else {
+        # we send the output to STDOUT because that's where PHP finds it
+        print @$stdout_buf;
         print @$stderr_buf;
+        exit 1;
     }
-    exit 0;
 }
 
@@ -111,5 +118,5 @@
 {
 
-    my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/$request_name'";
+    my $command = "$pstamptool -addreq -uri $request_file";
     $command .= " -dbname $dbname" if $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -143,5 +150,5 @@
     chomp $webreq_num;
 
-    print STDERR "$webreq_num\n";
+    print STDERR "$webreq_num\n" if $verbose;
 
     my $next = $webreq_num + 1;
