Index: trunk/pstamp/scripts/pstamp_insert_request.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_insert_request.pl	(revision 28081)
+++ trunk/pstamp/scripts/pstamp_insert_request.pl	(revision 28106)
@@ -114,31 +114,25 @@
 
 exit 0;
-
-# Temporary hack
-# webrequest number is stored in a file in the current directory
-#
-# get this number from the database
+# Ask the database for the next web request number
 sub get_webreq_num
 {
-    my $filename = "$workdir/webreq_num.txt";
-    if (! open IN, "+< $filename" ) {
-        my $initial_num = 1;
-        open IN, "> $filename" or die "can't open $filename";
-        print IN "$initial_num\n" or die "failed to initialize $filename";
-        close IN;
-        return $initial_num;
+    my $command = "$pstamptool -getwebrequestnum";
+    $command .= " -dbname $dbname" if $dbname;
+    $command .= " -dbserver $dbserver" if $dbserver;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        print STDERR @$stderr_buf;
+        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
+    }
+    my $webreq_num = ${$stdout_buf}[0];
+    chomp $webreq_num;
+
+    if (!$webreq_num) {
+        die("pstamptool -getwebreqnum returned no value");
     }
 
-    my $webreq_num = <IN>;
-    chomp $webreq_num;
+    # print STDERR "webreq_num $webreq_num\n";
 
-    print STDERR "$webreq_num\n" if $verbose;
-
-    my $next = $webreq_num + 1;
-    truncate IN, 0;
-    seek IN, 0, 0;
-    print IN "$next\n";
-
-    close IN;
     return $webreq_num;
 }
Index: trunk/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 28081)
+++ trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 28106)
@@ -23,5 +23,5 @@
 
 my $host = hostname();
-my $verbose = 0;
+my $verbose = 1;
 my $dbname;
 my $dbserver;
@@ -152,29 +152,25 @@
 exit 0;
 
-# Temporary hack
-# webrequest number is stored in a file in the current directory
-#
+# Ask the database for the next web request number
 sub get_webreq_num
 {
-    my $filename = "webreq_num.txt";
-    if (! open IN, "+< $filename" ) {
-        my $initial_num = 1;
-        open IN, "> $filename" or die "can't open $filename";
-        print IN "$initial_num\n" or die "failed to initialize $filename";
-        close IN;
-        return $initial_num;
+    my $command = "$pstamptool -getwebrequestnum";
+    $command .= " -dbname $dbname" if $dbname;
+    $command .= " -dbserver $dbserver" if $dbserver;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        print STDERR @$stderr_buf;
+        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
+    }
+    my $webreq_num = ${$stdout_buf}[0];
+    chomp $webreq_num;
+
+    if (!$webreq_num) {
+        die("pstamptool -getwebreqnum returned no value");
     }
 
-    my $webreq_num = <IN>;
-    chomp $webreq_num;
+    # print STDERR "webreq_num $webreq_num\n";
 
-    print STDERR "$webreq_num\n" if $verbose;
-
-    my $next = $webreq_num + 1;
-    truncate IN, 0;
-    seek IN, 0, 0;
-    print IN "$next\n";
-
-    close IN;
     return $webreq_num;
 }
