Index: trunk/DataStoreServer/scripts/dsreg
===================================================================
--- trunk/DataStoreServer/scripts/dsreg	(revision 16879)
+++ trunk/DataStoreServer/scripts/dsreg	(revision 17748)
@@ -9,5 +9,5 @@
 use Getopt::Long qw( GetOptions );
 use Pod::Usage qw( pod2usage );
-use Digest::MD5::File qw( file_md5_hex ); 
+use Digest::MD5::File qw( file_md5_hex );
 use DBI;
 use PS::IPP::Metadata::Config;
@@ -17,14 +17,14 @@
 
 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
-		       );
+                       $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;
@@ -43,4 +43,5 @@
 my $copyfiles;      # if set, copy files from this directory to the Data Store fileset
 my $datapath;       # source for files required if $linkfiles or $copyfiles
+my $dbname;                     # Database name
 
 my $ds_dir;
@@ -62,19 +63,20 @@
         'add'           =>      \$add,
         'del'           =>      \$del,
-	'product=s'	=>	\$product,
-	'fileset=s'	=>	\$fileset,
-	'type=s'	=>	\$fstype,
+        'product=s'     =>      \$product,
+        'fileset=s'     =>      \$fileset,
+        'type=s'        =>      \$fstype,
         'datapath=s'    =>      \$datapath,
         'link'          =>      \$linkfiles,
         'copy'          =>      \$copyfiles,
         'rm'            =>      \$remove,
-	'ps0=s'		=>	\$ps0,          # product specific columns 0 - 7
-	'ps1=s'		=>	\$ps1,
-	'ps2=s'		=>	\$ps2,
-	'ps3=s'		=>	\$ps3,
-	'ps4=s'		=>	\$ps4,
-	'ps5=s'		=>	\$ps5,
-	'ps6=s'		=>	\$ps6,
-	'ps7=s'		=>	\$ps7
+        'ps0=s'         =>      \$ps0,          # product specific columns 0 - 7
+        'ps1=s'         =>      \$ps1,
+        'ps2=s'         =>      \$ps2,
+        'ps3=s'         =>      \$ps3,
+        'ps4=s'         =>      \$ps4,
+        'ps5=s'         =>      \$ps5,
+        'ps6=s'         =>      \$ps6,
+        'ps7=s'         =>      \$ps7
+           'dbname'     =>      \$dbname,
 ) or pod2usage(2);
 
@@ -127,5 +129,5 @@
 
 my $dbserver = metadataLookupStr($siteConfig, 'DBSERVER');
-my $dbname   = metadataLookupStr($siteConfig, 'DBNAME');
+$dbname      = metadataLookupStr($siteConfig, 'DBNAME') unless defined $dbname;
 my $dbuser   = metadataLookupStr($siteConfig, 'DBUSER');
 my $dbpass   = metadataLookupStr($siteConfig, 'DBPASSWORD');
@@ -232,5 +234,5 @@
     while (<STDIN>) {
         $lineno++;
-        
+
         my $filename;
         my $filetype;
@@ -246,5 +248,5 @@
         $filetype = shift @fields;
 
-        # 
+        #
         # save any type specific fields provided in the string to be added to the
         # VALUES list for this file
@@ -265,9 +267,9 @@
                 ."($path does not exist.\n");
         }
-        
+
         # Get MD5 sum
         my $md5 = file_md5_hex($path);
 
-        my $hashref = { 
+        my $hashref = {
             'file'      => $filename,
             'bytes'     => $finfo[7],
@@ -283,5 +285,5 @@
         die("empty filelist");
     }
-    
+
     #
     # Prepare the fileset directory
@@ -316,5 +318,5 @@
                 die("failed to remove $fileset_dir");
             }
-            
+
             exit $PS_EXIT_UNKNOWN_ERROR;
         }
@@ -401,5 +403,5 @@
 
     pod2usage(
-        -msg => 
+        -msg =>
 "usage: $tmp[$#tmp] [--add|--del] --product prod_name --fileset fs_name --type fs_type [options]
 
@@ -422,5 +424,5 @@
     --ps0 - ps7 Optional product specific data
     --rm        with --del remove the fileset directory from the Data Store
-    
+
 $str",
         -exitval => 2
