[AudioLink-cvs]audiolink/code alsearch,1.24,1.25
Status: Alpha
Brought to you by:
amitshah
|
From: <ami...@us...> - 2003-12-05 12:32:42
|
Update of /cvsroot/audiolink/audiolink/code
In directory sc8-pr-cvs1:/tmp/cvs-serv5956
Modified Files:
alsearch
Log Message:
1. config file isn't perl code now; simple "a = b" stuff
2. command-line args override config file options
Index: alsearch
===================================================================
RCS file: /cvsroot/audiolink/audiolink/code/alsearch,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** alsearch 4 Dec 2003 16:13:07 -0000 1.24
--- alsearch 5 Dec 2003 12:32:39 -0000 1.25
***************
*** 141,151 ****
# execution starts here
- $config_file = "$ENV{HOME}/.audiolink/config";
-
- unless ($file_ret = do $config_file) {
- die "Couldn't parse the config file, $config_file: $@" if $@;
- die "Couldn't read the config file, $config_file: $!";
- die "Some problem occured with the config file, $config_file";
- }
# check for command-line arguments
--- 141,144 ----
***************
*** 183,186 ****
--- 176,198 ----
}
+ $config_file = "$ENV{HOME}/.audiolink/config";
+
+ if (-e $config_file) {
+ open(CONFFILE, $config_file);
+
+ # go through the config file
+ while (<CONFFILE>) {
+ if (/^\s*user\s*\=+\s*(\w+)/) {
+ chomp($user = $1) unless $user;
+ } elsif ( /^\s*pass(word)?\s*=\s*(\w+)/) {
+ chomp($password = $2) unless $password;
+ } elsif ( /^\s*host\s*=\s*(\w+)/) {
+ chomp($host = $1) unless $host;
+ }
+ }
+ } else {
+ warn "WARNING: config file not found. Use the audiolink script to create one.\n";
+ }
+
my $i = 0;
***************
*** 218,223 ****
$dbh = DBI->connect($dbi_string,$user,$password)
or die "$0: Error: Could not connect to the database! \
! Make sure that the DBI_PASS and DBI_USER environment variables are set.\n";
!
if ($target_dir_name) {
--- 230,234 ----
$dbh = DBI->connect($dbi_string,$user,$password)
or die "$0: Error: Could not connect to the database! \
! Check the user, password and host fields for the MySQL connection.";
if ($target_dir_name) {
|