Index: trunk/DataStoreServer/scripts/dsprodtool
===================================================================
--- trunk/DataStoreServer/scripts/dsprodtool	(revision 24196)
+++ trunk/DataStoreServer/scripts/dsprodtool	(revision 25664)
@@ -12,4 +12,6 @@
 use PS::IPP::Metadata::Config;
 use File::Copy;
+
+use Term::ReadKey;
 
 use PS::IPP::Config qw($PS_EXIT_SUCCESS
@@ -36,4 +38,5 @@
 my $dsroot;
 my $dbname;
+my $dbpass;
 
 my $add;
@@ -78,4 +81,23 @@
 } else {
     $product = $del;
+    if (! -t STDIN) {
+        die "cannot delete product from script\n";
+    }
+    print "*** Delete the Data Store Product $product? ***\n";
+    print "*** to delete $product answer YES, and give password ***\n";
+    print "*** WARNING this action is permanant *** \n";
+    print "Delete? (YES/[n]): ";
+
+    my $line = ReadLine(0);
+    chomp $line;
+    exit 1 if !$line or ($line ne "YES");
+
+    print "password: ";
+    ReadMode('noecho');
+    $line = ReadLine(0);
+    ReadMode('normal');
+    print "\n";
+    chomp $line;
+    $dbpass = $line;
 }
 
@@ -106,11 +128,8 @@
     unless defined $dbname;
 my $dbuser   = metadataLookupStr($siteConfig, 'DS_DBUSER');
-my $dbpass   = metadataLookupStr($siteConfig, 'DS_DBPASSWORD');
+$dbpass   = metadataLookupStr($siteConfig, 'DS_DBPASSWORD') if !$dbpass;
 exit ($PS_EXIT_CONFIG_ERROR) unless defined $dbserver and $dbname and $dbuser and $dbpass;
 
 my $dsn = "DBI:mysql:host=$dbserver;database=$dbname";
-
-my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n";
-
 
 my $product_dir = "$dsroot/$product";
@@ -118,4 +137,5 @@
 
 if ($del) {
+    my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n";
     #
     # delete product
@@ -129,14 +149,4 @@
     }
     my $prod_id = $prod_row->{prod_id};
-
-    # if requested, remove the product directory
-    if ($remove) {
-        if (system "rm -r $product_dir") {
-            die("failed to remove $product_dir");
-        }
-    } else  {
-        # otherwise just zap the index script
-        unlink("$index_script_name");
-    }
 
 
@@ -152,4 +162,17 @@
     $dbh->do("DELETE from dsProduct where prod_id = $prod_id");
 
+    print "Product $product deleted.\n";
+
+    # if requested, remove the product directory
+    if ($remove) {
+        print "Removing files from $product.\n";
+        if (system "rm -r $product_dir") {
+            die("failed to remove $product_dir");
+        }
+    } else  {
+        # otherwise just zap the index script
+        unlink("$index_script_name");
+    }
+
     exit 0;
 
@@ -158,4 +181,6 @@
     # add a new product
     #
+    my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n";
+
     my $stmt = $dbh->prepare("SELECT prod_id FROM dsProduct WHERE prod_name = \'$product\'");
     $stmt->execute();
