Index: /trunk/pstamp/scripts/pstamp_get_image_job.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 16959)
+++ /trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 16959)
@@ -0,0 +1,140 @@
+#!/usr/bin/env perl
+#
+# Execute a get_image job for the postage stamp server
+#
+
+use strict;
+use warnings;
+
+use Getopt::Long qw( GetOptions );
+use Pod::Usage qw( pod2usage );
+use DBI;
+use PS::IPP::Metadata::Config;
+use PS::IPP::Metadata::Stats;
+use PS::IPP::Metadata::List qw( parse_md_list );
+use File::Copy;
+use File::Basename;
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       metadataLookupStr
+		       metadataLookupBool
+		       caturi
+		       );
+my $product;
+my $fileset;
+
+my $uri;
+my $out_dir;
+
+my $verbose = 1;
+my $ipprc;
+
+#
+# parse args
+#
+
+GetOptions(
+        'uri=s'           =>      \$uri,
+        'out_dir=s'       =>      \$out_dir,
+) or pod2usage(2);
+
+my $err = "";
+
+if (!$uri) {
+    die("--uri is required to specify the file list");
+}
+if (!$out_dir) {
+    die("--out_dir is required to specify the output fileset");
+}
+
+# collapse any multiple slashes in output_dir
+$out_dir = File::Spec->canonpath($out_dir);
+
+my @path = split(/\//, $out_dir);
+
+my $nelem = @path;
+if ($nelem < 2) {
+    die("$out_dir is not a valid output fileset directory");
+}
+$fileset = $path[$nelem-1];
+$product = $path[$nelem-2];
+
+$_ = $out_dir;
+my ($ds_dir) = m%(.*)/$product/$fileset%;
+
+if ($verbose) {
+    print STDERR "DS root:  $ds_dir\n";
+    print STDERR "Product:  $product\n";
+    print STDERR "Fileset:  $fileset\n";
+    print STDERR "Filelist: $uri\n";
+}
+
+
+if (!stat("$ds_dir/index.txt")) {
+    $err .= "Data Store not found at '$ds_dir'.\n"
+}
+
+show_usage("Invalid product '$product'.")
+    unless defined stat("$ds_dir/$product/index.txt");
+
+if (! open(INPUT, "<$uri") ) {
+    die("failed to open file list: $uri");
+}
+
+my $reglist = "$out_dir/reglist";
+if (! open(REGLIST, ">$reglist") ) {
+    die("failed to open registration list: $reglist");
+}
+
+my @files;
+while (<INPUT>) {
+    chomp;
+    my @fields = split /\|/;
+    my $pathname = shift @fields;
+
+    #my ($volume, $directories, $filename) = File::Spec->splitpath($pathname);
+
+    ($pathname , my $filename) = resolvepath($pathname);
+
+    if ($verbose) {
+        print STDERR "$pathname @fields\n";
+    }
+
+    if (! symlink $pathname, "$out_dir/$filename" ) {
+        die("failed trying to create symlink to $pathname in $out_dir");
+    }
+
+    print REGLIST "$filename|";
+    foreach my $f (@fields) {
+        print REGLIST "$f|";
+    }
+    print REGLIST "\n";
+}
+
+close(REGLIST);
+
+#only thing left to do is register the fileset
+exec "dsreg < $reglist --add --product $product --fileset $fileset --type PSRESULTS";
+
+
+sub resolvepath {
+    my $pathname = $_[0];
+
+    my $slash = index($pathname, "/");
+    if ($slash != 0) {
+        if (!$ipprc) {
+            $ipprc = PS::IPP::Config->new();
+        }
+        $pathname = $ipprc->convert_filename_absolute($pathname);
+    }
+
+    my $file = basename($pathname);
+
+    return ($pathname, $file);
+}
Index: /trunk/pstamp/scripts/pstamp_listjobs.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_listjobs.pl	(revision 16958)
+++ /trunk/pstamp/scripts/pstamp_listjobs.pl	(revision 16959)
@@ -2,5 +2,5 @@
 ###
 ### pstamp_listjobs.pl
-### list the job_id, state, and uri for the postage stamp jobs queued for a given 
+### list the job_id, state, and data store uri for the postage stamp jobs queued for a given 
 ### postage stamp request id
 ###
@@ -80,9 +80,23 @@
 if (! @psjobs) {
     print STDERR "no postage stamp jobs for request $request_id found\n";
-    exit 1;
+    exit 0;
 }
 
 foreach my $job (@psjobs) {
-    print "$job->{job_id} $job->{state} $job->{outputBase}.fits\n";
+    #
+    # convert from filename to data store relative uri
+    # XXX arguably we shouldn't do this here. this should be a function
+    # of the web interface. But since this script is only used by
+    # the web interface ....
+    my $i = index($job->{outputBase}, "dsroot/");
+
+    my $uri;
+    if ($i > 0) {
+        $uri = "/ds" . substr($job->{outputBase}, $i + 6) . ".fits";
+    } else {
+        $uri = "$job->{outputBase}" . ".fits";
+    }
+
+    print "$job->{job_id} $job->{state} $uri\n";
 }
 
Index: /trunk/pstamp/scripts/pstamp_runcommand.sh
===================================================================
--- /trunk/pstamp/scripts/pstamp_runcommand.sh	(revision 16958)
+++ /trunk/pstamp/scripts/pstamp_runcommand.sh	(revision 16959)
@@ -65,3 +65,5 @@
 #### Finally, execute the command given by the command line arguments
 
+umask 0
+
 $*
Index: /trunk/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 16958)
+++ /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 16959)
@@ -42,4 +42,6 @@
 		       );
 
+use Cwd;
+
 my $missing_tools;
 
@@ -54,5 +56,4 @@
 }
 
-
 # if -list is used, it must be the first argument
 my $listMode;
@@ -63,5 +64,6 @@
 }
 
-my $request_file = "request_file.$$.fits";
+my $cur_dir = getcwd();
+my $request_file = "$cur_dir/request_file.$$.fits";
 {
     my $command = "$pstamprequest $request_file @ARGV";
@@ -73,5 +75,4 @@
     }
 }
-
 
 # ok at this point we have a request file add it to the database (unless we're in listMode)
@@ -95,5 +96,5 @@
 {
 
-    my $command = "$pstamptool -addreq -uri $request_file";
+    my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/web\$REQ_ID\'";
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbosity);
@@ -105,16 +106,4 @@
 }
 
-# parse the file to queue the jobs
-{
-    my $command = "$pstampparser_run $request_id";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbosity);
-    unless ($success) {
-        print STDERR @$stderr_buf;
-        die("Unable to perform pstamparser_run -addreq: $error_code");
-    }
-}
-
-#                   note: $request_id still has a newline
 print "$request_id";
 
