#!/usr/bin/perl -w ########################################################################### # # jdb2txt.pl -- convenience script to access JDBM datbases produced by Greenstone # # A component of the Greenstone digital library software # from the New Zealand Digital Library Project at the # University of Waikato, New Zealand. # # Copyright (C) 2012 New Zealand Digital Library Project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ########################################################################### # Wrapper script that gives similar command-line functionality to the # db2txt and txt2db scripts available for GDBM databases # Save you having to type in the mouthful: # java -cp $GSDLHOME/lib/java/jdbm.jar:$GSDLHOME/bin/java/JDBMWrapper.jar Jdb2Txt jdbm-file.jdb # # for Unix, or # # java -cp %GSDLHOME%\lib\java\jdbm.jar;$GSDLHOME\bin\java/\DBMWrapper.jar Jdb2Txt jdbm-file.jdb # # for Windows. BEGIN { die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'}; die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'}; unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); } use strict; use util; use File::Basename; if (scalar(@ARGV)==0) { my ($progname,$dir) = &File::Basename::fileparse($0); print STDERR "Usage: $progname file.jdb\n"; exit -1; } my $jdbm_jar = &util::filename_cat($ENV{'GSDLHOME'},"lib","java","jdbm.jar"); my $jdbmwrapper_jar = &util::filename_cat($ENV{'GSDLHOME'},"bin","java","JDBMWrapper.jar"); &util::envvar_prepend("CLASSPATH",$jdbm_jar); &util::envvar_prepend("CLASSPATH",$jdbmwrapper_jar); my $cmd = "java Jdb2Txt " . join(" ", map {$_ = "\"$_\""} @ARGV); if (system($cmd)!=0) { print STDERR "Error: Failed to run cmd\n $cmd\n"; print STDERR " $!\n"; exit -1; }