Index: /trunk/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 35353)
+++ /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 35354)
@@ -5,9 +5,4 @@
 #
 # The arguments are the command line parameters for the program psmkreq
-#
-# Unless the argument -list is provided the output is the request id for the resulting request
-#
-# If -list is the first argument, the request file is built and parsed and the
-# the selected "input" uris are listed on stdout.
 #
 # Note: Despite the name there nothing particularly web specific about this program.
@@ -23,12 +18,20 @@
 
 my $host = hostname();
-my $verbose = 1;
+my $verbose = 0;
 my $dbname;
 my $dbserver;
+my $pretend;
+my $label = 'WEB';
+my $req_name_prefix = 'web';
+my $username;
 
 GetOptions(
     'dbname=s'      =>  \$dbname,
     'dbserver=s'    =>  \$dbserver,
-    'verbose'       => \$verbose,
+    'label=s'       =>  \$label,
+    'username=s'    =>  \$username,
+    'prefix=s'      =>  \$req_name_prefix,
+    'pretend'       =>  \$pretend,
+    'verbose'       =>  \$verbose,
 );
 
@@ -36,6 +39,6 @@
 
 if ($verbose) {
-    print "\n\n";
-    print "Starting script $0 on $host\n\n";
+    print STDERR "\n\n";
+    print STDERR "Starting script $0 on $host\n\n";
 }
 
@@ -70,16 +73,19 @@
 # make a request file
 my $cur_dir = getcwd();
+
 #print STDERR "cur_dir is $cur_dir\n";
 
-my $datestr = strftime "%Y%m%d", gmtime;
+my $datestr = strftime "%Y/%m/%d", gmtime;
 my $datedir = "$cur_dir/webreq/$datestr";
 if (! -e $datedir ) {
-    if (!  mkdir $datedir ) {
-        print STDERR  "failed to create working directory $datedir";
+    my $rc = system "mkdir -p $datedir";
+    if ($rc) {
+        my $status = $rc >> 8;
+        print STDERR  "failed to create working directory $datedir: $rc $status";
         exit $PS_EXIT_CONFIG_ERROR;
     }
 }
 
-my $request_name = "web_" . get_webreq_num();
+my $request_name = $req_name_prefix . '_' . get_webreq_num();
 my $request_file = "$datedir/$request_name.fits";
 {
@@ -96,8 +102,9 @@
 # Queue the request
 my $req_id = 0;
-{
+unless ($pretend) {
 
     my $command = "$pstamptool -addreq -uri $request_file -ds_id 0";
-    $command .= " -label WEB";
+    $command .= " -label $label";
+    $command .= " -username $username" if $username;
     $command .= " -dbname $dbname" if $dbname;
     $command .= " -dbserver $dbserver" if $dbserver;
@@ -109,4 +116,5 @@
     }
     $req_id = ${$stdout_buf}[0];
+    chomp $req_id;
 }
 
