my ( $options, $user, $password, @databases, $database );
-$user = $ENV{ "USER" };
-$password = $ENV{ "USER" };
+$user = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
$options = Maasha::Biopieces::parse_options(
[
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my ( $default_user, $default_password, $options, $in, $out, $record, $dbh, $results );
+my ( $user, $password, $options, $in, $out, $record, $dbh, $results );
-$default_user = Maasha::UCSC::ucsc_get_user();
-$default_password = Maasha::UCSC::ucsc_get_password();
+$user = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
$options = Maasha::Biopieces::parse_options(
[
- { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
- { long => 'query', short => 'q', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
- { long => 'user', short => 'u', type => 'string', mandatory => 'no', default => $default_user, allowed => undef, disallowed => undef },
- { long => 'password', short => 'p', type => 'string', mandatory => 'no', default => $default_password, allowed => undef, disallowed => undef },
+ { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ { long => 'query', short => 'q', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ { long => 'user', short => 'u', type => 'string', mandatory => 'no', default => $user, allowed => undef, disallowed => undef },
+ { long => 'password', short => 'p', type => 'string', mandatory => 'no', default => $password, allowed => undef, disallowed => undef },
]
);
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my ( $options, $in, $out, $record, %table_hash, $dbh, $table );
+my ( $options, $user, $password, $in, $out, $record, %table_hash, $dbh, $table );
+
+$user = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
$options = Maasha::Biopieces::parse_options(
[
- { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
- { long => 'tables', short => 't', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
- { long => 'keys', short => 'k', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
- { long => 'user', short => 'u', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
- { long => 'password', short => 'p', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ { long => 'tables', short => 't', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'keys', short => 'k', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'user', short => 'u', type => 'string', mandatory => 'no', default => $user, allowed => undef, disallowed => undef },
+ { long => 'password', short => 'p', type => 'string', mandatory => 'no', default => $password, allowed => undef, disallowed => undef },
]
);
my ( $options, $user, $password, $dbh, $in, $out, $tmp_dir, $tmp_file, $fh_out, $record, $key, $type_hash, $i, @keys, $line );
-$user = $ENV{ "USER" };
-$password = $ENV{ "USER" };
+$user = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
$options = Maasha::Biopieces::parse_options(
[
}
+sub biopiecesrc
+{
+ # Martin A. Hansen, July 2009.
+
+ # Read Biopiece configuration info from .biopiecesrc.
+ # and returns the value of a given key.
+
+ my ( $key, # configuration key
+ ) = @_;
+
+ # Returns a string.
+
+ my ( $file, $fh, $record );
+
+ $file = "$ENV{ 'HOME' }/.biopiecesrc";
+
+ return undef if not -f $file;
+
+ $fh = Maasha::Filesys::file_read_open( $file );
+ $record = get_record( $fh );
+ close $fh;
+
+ if ( exists $record->{ $key } ) {
+ return $record->{ $key };
+ } else {
+ return undef;
+ }
+}
+
+
END
{
clean_tmp();