--- loncom/debugging_tools/db_copy.pl 2006/08/24 22:46:30 1.1 +++ loncom/debugging_tools/db_copy.pl 2006/10/03 18:01:01 1.3 @@ -10,8 +10,12 @@ use LONCAPA; use LONCAPA::Configuration; use Cwd; -my $dump_db = './dump_db'; -my $dir = './test'; +my $dump_db = '/home/httpd/perl/debug/dump_db_static_32'; +my $create_db = '/home/httpd/perl/debug/create_db_dynamic'; +if (!-x $dump_db || !-x $create_db) { + print("Unable to run needed helper programs\n $dump_db\n $create_db\n."); + exit(-1); +} my %perlvar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; @@ -47,23 +51,11 @@ sub process_db { return if ($_!~m/\.db$/); my $file = $_; my $dbref =&lock_db($file); - print("attempting $dbref\n"); + print("attempting $file\n"); my %newdb; my $new_file = $file.'.new'; - if (!tie(%newdb,'GDBM_File',$new_file,&GDBM_WRCREAT(),0640)) { - die("unable to create new db $new_file $! $@"); - } - open(my $fh,"$dump_db -f $file|"); - while (my $entry = <$fh>) { - chomp($entry); - if ($entry =~/^ERROR:/) { - die($entry); - } - my ($key,$value) = split(' -> ',$entry,2); - $newdb{&unescape($key)} = &unescape($value); - } - print("finishing $dbref\n"); - untie(%newdb); + system("$dump_db -f $file|$create_db -f $new_file"); +# print("finishing $dbref\n"); untie($dbref); system("/bin/mv $file $file.old"); system("/bin/mv $file.new $file"); @@ -76,8 +68,7 @@ sub main { no_chdir => 1, wanted => \&process_db, }, - $dir - #$perlvar->{'lonUsersDir'} + $perlvar{'lonUsersDir'} ); }