root/main/trunk/greenstone2/bin/script/jdb2txt.pl @ 26490

Revision 26490, 2.4 KB (checked in by davidb, 8 years ago)

Convenience command-line script to access JDBM databases produced by Greenstone

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# jdb2txt.pl -- convenience script to access JDBM datbases produced by Greenstone
6#
7# A component of the Greenstone digital library software
8# from the New Zealand Digital Library Project at the
9# University of Waikato, New Zealand.
10#
11# Copyright (C) 2012 New Zealand Digital Library Project
12#
13# This program is free software; you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 2 of the License, or
16# (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26#
27###########################################################################
28
29
30# Wrapper script that gives similar command-line functionality to the
31# db2txt and txt2db scripts available for GDBM databases
32
33# Save you having to type in the mouthful:
34#  java -cp $GSDLHOME/lib/java/jdbm.jar:$GSDLHOME/bin/java/JDBMWrapper.jar Jdb2Txt jdbm-file.jdb
35#
36# for Unix, or
37#
38#  java -cp %GSDLHOME%\lib\java\jdbm.jar;$GSDLHOME\bin\java/\DBMWrapper.jar Jdb2Txt jdbm-file.jdb
39#
40# for Windows.
41
42
43
44BEGIN {
45    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
46    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
47    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
48}
49
50use strict;
51use util;
52
53use File::Basename;
54
55if (scalar(@ARGV)==0) {
56    my ($progname,$dir) = &File::Basename::fileparse($0);
57
58    print STDERR "Usage: $progname file.jdb\n";
59    exit -1;
60}
61
62my $jdbm_jar = &util::filename_cat($ENV{'GSDLHOME'},"lib","java","jdbm.jar");
63my $jdbmwrapper_jar = &util::filename_cat($ENV{'GSDLHOME'},"bin","java","JDBMWrapper.jar");
64
65&util::envvar_prepend("CLASSPATH",$jdbm_jar);
66&util::envvar_prepend("CLASSPATH",$jdbmwrapper_jar);
67
68my $cmd = "java Jdb2Txt " . join(" ", map {$_ = "\"$_\""} @ARGV);
69
70if (system($cmd)!=0) {
71    print STDERR "Error: Failed to run cmd\n  $cmd\n";
72    print STDERR "  $!\n";
73    exit -1;
74}
75
76
Note: See TracBrowser for help on using the browser.