Index: /main/trunk/greenstone2/bin/script/explode_metadata_database.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/explode_metadata_database.pl	(revision 28559)
+++ /main/trunk/greenstone2/bin/script/explode_metadata_database.pl	(revision 28560)
@@ -14,4 +14,6 @@
 use encodings;
 use extrametautil;
+use util;
+use FileUtils;
 use printusage;
 use parse2;
@@ -87,5 +89,5 @@
 	'type' => "string",
 	# parsearg left "" as default
-	#'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
+	#'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
 	'deft' => "",
 	'reqd' => "no",
@@ -349,5 +351,5 @@
 
     # Explode means just that: the original file is deleted
-    &util::rm($filename);
+    &FileUtils::removeFiles($filename);
     $plugobj->clean_up_after_exploding();
 
@@ -364,7 +366,7 @@
 	die "Error: document directory $documents_directory already exists (bailing).\n";
     }
-    &util::mk_dir($documents_directory);
-
-    my $documents_metadata_xml_file = &util::filename_cat($documents_directory, "metadata.xml");
+    &FileUtils::makeDirectory($documents_directory);
+
+    my $documents_metadata_xml_file = &FileUtils::filenameConcatenate($documents_directory, "metadata.xml");
     if (-e $documents_metadata_xml_file) {
 	die "Error: documents metadata.xml file $documents_metadata_xml_file already exists (bailing).\n";
@@ -427,5 +429,5 @@
 		    # by first of all stripping any trailing slash and then always ensuring one is used through filename_cat
 		    $document_prefix =~ s/(\/|\\)$//;
-		    $document_file_full = &util::filename_cat($document_prefix, "$value$document_suffix");
+		    $document_file_full = &FileUtils::filenameConcatenate($document_prefix, "$value$document_suffix");
 		} else { # the doc prefix may also contain the prefix of the actual *filename* following the directory
 		    $document_file_full = $document_prefix . $value . $document_suffix;
@@ -560,5 +562,8 @@
 	$document_file_full =~ /([^\/]+)$/;
 	$document_file_name = $1;
-	$local_document_file = &util::filename_cat($documents_directory, $document_file_name);
+	$local_document_file = &FileUtils::filenameConcatenate($documents_directory, $document_file_name);
+
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
 	my $wget_options = "--quiet";
@@ -576,5 +581,5 @@
     else {
 	# convert the dirseps in filepath to correct dir sep for OS
-	$document_file_full = &util::filename_cat($document_file_full);
+	$document_file_full = &FileUtils::filenameConcatenate($document_file_full);
 	my $dir_sep = &util::get_os_dirsep();
 
@@ -588,11 +593,11 @@
 	if (!$is_absolute) {
 	    $document_file_full 
-		= &util::filename_cat($orig_base_dir,$document_file_full);
-	}
-
-	$local_document_file = &util::filename_cat($documents_directory, $document_file_name);
+		= &FileUtils::filenameConcatenate($orig_base_dir,$document_file_full);
+	}
+
+	$local_document_file = &FileUtils::filenameConcatenate($documents_directory, $document_file_name);
 
 	if (-e $document_file_full) {
-	    &util::cp($document_file_full, $documents_directory);
+	    &FileUtils::copyFiles($document_file_full, $documents_directory);
 	}
 	
@@ -606,5 +611,5 @@
 		# file local to metadata record
 		# => copy has been made successfully, so remove original
-		&util::rm($document_file_full);
+		&FileUtils::removeFiles($document_file_full);
 	    }
 	}
Index: /main/trunk/greenstone2/bin/script/grab_collection.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/grab_collection.pl	(revision 28559)
+++ /main/trunk/greenstone2/bin/script/grab_collection.pl	(revision 28560)
@@ -1,4 +1,5 @@
 #!/usr/bin/perl -w
 
+use util;
 
 # Both this script and its associated process_html.pl were written by
@@ -550,4 +551,7 @@
 	}
 	
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
+
 	# wget is set to 'q - quiet' and 'nc - dont clobber existing files'
 	$kommand = $wget.' -qnc --directory-prefix='.$temp_outputdir.$image_dir.' "'.$found.'"';
Index: /main/trunk/greenstone2/bin/script/gsWget.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/gsWget.pl	(revision 28559)
+++ /main/trunk/greenstone2/bin/script/gsWget.pl	(revision 28560)
@@ -36,9 +36,10 @@
 
 use util;
+use FileUtils;
 
 # wget should live in the Greenstone directory structure
 # we'll bail if we can't find it
 my $exe = &util::get_os_exe ();
-my $cmd = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
+my $cmd = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
 $cmd .= $exe;
 if (! -e "$cmd") {
@@ -52,4 +53,7 @@
     $cmd = "wget";
 }
+
+# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
 # command-line parameters
Index: /main/trunk/greenstone2/bin/script/importfrom.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/importfrom.pl	(revision 28559)
+++ /main/trunk/greenstone2/bin/script/importfrom.pl	(revision 28560)
@@ -40,4 +40,5 @@
 use colcfg;
 use util;
+use FileUtils;
 use parsargv;
 use FileHandle;
@@ -62,5 +63,5 @@
     print STDERR "   -debug                 Print imported text to STDOUT\n";
     print STDERR "   -collectdir directory  Collection directory (defaults to " .
-	&util::filename_cat ($ENV{'GSDLHOME'}, "collect") . ")\n";
+	&FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect") . ")\n";
     print STDERR "   -out                   Filename or handle to print output status to.\n";
     print STDERR "                          The default is STDERR\n\n";
@@ -96,4 +97,7 @@
 {
     my ($wget_cmd,$out,$verbosity) = @_;
+
+    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
     if ($verbosity>2) {
@@ -210,9 +214,12 @@
     print $out "Getting document $doc_url\n";
 
-    &util::mk_dir($output_dir)  if (!-e "$output_dir");
-
-    my $full_id_fname = &util::filename_cat($output_dir,$id_fname);
+    &FileUtils::makeDirectory($output_dir)  if (!-e "$output_dir");
+
+    my $full_id_fname = &FileUtils::filenameConcatenate($output_dir,$id_fname);
 
     my $wget_cmd = "wget $wgetopt --quiet -O \"$full_id_fname\" \"$doc_url\"";
+
+    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
     if (system($wget_cmd)!=0) {
@@ -245,8 +252,11 @@
 	my $i_os = $i; #convert OAI set separators (:) to OS dir sep
 	$i_os =~ s/:/$ds/g;
-	my $file_i = &util::filename_cat($output_dir,"$i_os.oai");
+	my $file_i = &FileUtils::filenameConcatenate($output_dir,"$i_os.oai");
 
 	# obtain record
 	my $wget_cmd = "wget $wgetopt -q -O - \"$url\"";
+
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
 	open (OAIIN,"$wget_cmd|")
@@ -267,5 +277,5 @@
 	my ($i_dir,$unused) = dir_file_split($file_i_url);
 
-	&util::mk_all_dir($i_dir);
+	&FileUtils::makeAllDirectories($i_dir);
 
 	# look out for identifier tag in metadata section
@@ -286,5 +296,5 @@
 ##			$revised_doc_url =~ s/hdl\.handle\.net/mcgonagall.cs.waikato.ac.nz:8080\/dspace\/handle/;
 			
-			my $srcdocs_dir = &util::filename_cat($i_dir,"srcdocs");
+			my $srcdocs_dir = &FileUtils::filenameConcatenate($i_dir,"srcdocs");
 
 			if (get_oai_document($revised_doc_url,$srcdocs_dir, $out)) {			   
@@ -360,5 +370,5 @@
     # get acquire list
     my $acquire = [];
-    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
+    $configfilename = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     if (-e $configfilename) {
 	$collectcfg = &colcfg::read_collect_cfg ($configfilename);
@@ -383,5 +393,5 @@
     # fill in the default import directory if none
     # were supplied, turn all \ into / and remove trailing /
-    $importdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
+    $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq "";
     $importdir =~ s/[\\\/]+/\//g;
     $importdir =~ s/\/$//;
@@ -391,5 +401,5 @@
 	print $out "Warning - removing current contents of the import directory\n";
 	print $out "          in preparation for the acquire\n";
-	&util::rm_r ($importdir);
+	&FileUtils::removeFilesRecursive($importdir);
     }
 
Index: /main/trunk/greenstone2/bin/script/mirror.pl
===================================================================
--- /main/trunk/greenstone2/bin/script/mirror.pl	(revision 28559)
+++ /main/trunk/greenstone2/bin/script/mirror.pl	(revision 28560)
@@ -84,9 +84,9 @@
 
     # get the etc directory
-    $etcdir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc");
+    $etcdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "etc");
     
     # check the collection configuration file for options
     my $interval = 0;
-    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, 
+    $configfilename = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, 
 					   "etc", "collect.cfg");
     if (-e $configfilename) {
@@ -107,5 +107,5 @@
     # make sure there is an import directory
     if (! -e "$importdir") {
-	&util::mk_dir($importdir);
+	&FileUtils::makeDirectory($importdir);
     }
 
Index: /main/trunk/greenstone2/perllib/classify/Phind.pm
===================================================================
--- /main/trunk/greenstone2/perllib/classify/Phind.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/classify/Phind.pm	(revision 28560)
@@ -167,4 +167,8 @@
 
     # Ensure the Phind generate scripts are in place
+
+    # the suffix binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
+
     my $file1 = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "suffix");
     $file1 .= ".exe" if $ENV{'GSDLOS'} =~ /^windows$/;
Index: /main/trunk/greenstone2/perllib/doc.pm
===================================================================
--- /main/trunk/greenstone2/perllib/doc.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/doc.pm	(revision 28560)
@@ -373,4 +373,7 @@
     my $hashfile_exe = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin",
 					   $ENV{'GSDLOS'},"hashfile$osexe");
+
+    &util::set_gnomelib_env(); # gnomelib_env (particularly lib/libiconv2.dylib) required to run the hashfile executable on Mac Lions
+    # The subroutine will set the gnomelib env once for each subshell launched, by first testing if GEXTGNOME is not already set
 
     my $result = "NULL";
Index: /main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
===================================================================
--- /main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm	(revision 28560)
@@ -35,4 +35,5 @@
 use strict;
 use Cwd;
+use util;
 use IPC::Open3;
 use IO::Select;
@@ -139,4 +140,7 @@
 
     my $self = new BaseDownload($getlist,$inputargs,$hashArgOptLists);
+
+    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 
     return bless $self, $class;
Index: /main/trunk/greenstone2/perllib/g2futil.pm
===================================================================
--- /main/trunk/greenstone2/perllib/g2futil.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/g2futil.pm	(revision 28560)
@@ -9,5 +9,5 @@
     }
 
-    my $fedora_client_bin = &util::filename_cat($ENV{'FEDORA_HOME'},"client","bin");
+    my $fedora_client_bin = &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'},"client","bin");
     &util::envvar_append("PATH",$fedora_client_bin);
 }
@@ -15,4 +15,5 @@
 use strict;
 use util;
+use FileUtils;
 
 sub run_cmd_old
@@ -186,6 +187,6 @@
     #$ENV{'fgsPassword'} = $options->{'password'};    
 
-    #my $prog = &util::filename_cat($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
-    my $prog = &util::filename_cat($fedoragsearch_webapp, "client", "runRESTClient.sh");
+    #my $prog = &FileUtils::filenameConcatenate($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
+    my $prog = &FileUtils::filenameConcatenate($fedoragsearch_webapp, "client", "runRESTClient.sh");
 
     my $gsearch_commands = "updateIndex deletePid"; # deletePID
@@ -214,6 +215,6 @@
     #$ENV{'fgsPassword'} = $options->{'password'};    
 
-    #my $prog = &util::filename_cat($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
-    my $prog = &util::filename_cat($fedoragsearch_webapp, "client", "runRESTClient.sh");
+    #my $prog = &FileUtils::filenameConcatenate($ENV{'FEDORA_GSEARCH'}, "runRESTClient.sh");
+    my $prog = &FileUtils::filenameConcatenate($fedoragsearch_webapp, "client", "runRESTClient.sh");
     
     my $gsearch_commands = "updateIndex fromPid"; # fromPID
@@ -231,12 +232,12 @@
     # if GS3, first look for a fedoragsearch webapp installed in Greenstone's tomcat
     if(defined $ENV{'GSDL3SRCHOME'}) {
-	$fedoragsearch_webapp = &util::filename_cat($ENV{'GSDL3SRCHOME'},"packages","tomcat","webapps","fedoragsearch");	
-	return $fedoragsearch_webapp if (&util::dir_exists($fedoragsearch_webapp));
+	$fedoragsearch_webapp = &FileUtils::filenameConcatenate($ENV{'GSDL3SRCHOME'},"packages","tomcat","webapps","fedoragsearch");	
+	return $fedoragsearch_webapp if (&FileUtils::directoryExists($fedoragsearch_webapp));
     }
 
     # next look for a fedoragsearch webapp installed in Fedora's tomcat
     if(defined $ENV{'FEDORA_HOME'}) {
-	$fedoragsearch_webapp =  &util::filename_cat($ENV{'FEDORA_HOME'},"tomcat","webapps","fedoragsearch");
-	return $fedoragsearch_webapp if (&util::dir_exists($fedoragsearch_webapp));
+	$fedoragsearch_webapp =  &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'},"tomcat","webapps","fedoragsearch");
+	return $fedoragsearch_webapp if (&FileUtils::directoryExists($fedoragsearch_webapp));
     }
 
@@ -287,5 +288,5 @@
 
     if (opendir(DIR, $full_dir)) {
-	my @sub_dirs = grep { ($_ !~ /^\./) && (-d &util::filename_cat($full_dir,$_)) } readdir(DIR);
+	my @sub_dirs = grep { ($_ !~ /^\./) && (-d &FileUtils::filenameConcatenate($full_dir,$_)) } readdir(DIR);
 	closedir DIR;
 
@@ -294,10 +295,10 @@
 	
 	foreach my $hd (@hash_dirs) {
-	    my $full_hash_dir = &util::filename_cat($full_dir,$hd);
+	    my $full_hash_dir = &FileUtils::filenameConcatenate($full_dir,$hd);
 	    push(@$all_dirs,$full_hash_dir);
 	}
 
 	foreach my $rd (@rec_dirs) {
-	    my $full_rec_dir = &util::filename_cat($full_dir,$rd);
+	    my $full_rec_dir = &FileUtils::filenameConcatenate($full_dir,$rd);
 	    rec_get_all_hash_dirs($full_rec_dir,$all_dirs);
 	}	    
@@ -329,5 +330,5 @@
     my $hash_id = undef;
 
-    my $docmets_filename = &util::filename_cat($hash_dir,"docmets.xml");
+    my $docmets_filename = &FileUtils::filenameConcatenate($hash_dir,"docmets.xml");
 
     if (open(DIN,"<$docmets_filename"))
@@ -372,17 +373,17 @@
     # to temporarily set CATALINA_HOME to fedora's tomcat. (Catalina is undefined for GS2.)
     my $gs_catalina_home = $ENV{'CATALINA_HOME'} if defined $ENV{'CATALINA_HOME'};
-    $ENV{'CATALINA_HOME'} = &util::filename_cat($ENV{'FEDORA_HOME'}, "tomcat");
+    $ENV{'CATALINA_HOME'} = &FileUtils::filenameConcatenate($ENV{'FEDORA_HOME'}, "tomcat");
     
     # 1. Find out which folder to write to: fedora_host or localhost 
     # whichever contains fedora.xml is the one we want (if none, exit with error value?)
     my $fedora_home = $ENV{'FEDORA_HOME'};
-    my $base_path = &util::filename_cat($fedora_home, "tomcat", "conf", "Catalina");
-
-    my $host_path = &util::filename_cat($base_path, $fedora_host);
-    my $xmlFile = &util::filename_cat($host_path, "fedora.xml");
+    my $base_path = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "conf", "Catalina");
+
+    my $host_path = &FileUtils::filenameConcatenate($base_path, $fedora_host);
+    my $xmlFile = &FileUtils::filenameConcatenate($host_path, "fedora.xml");
     if (!-e $xmlFile) {
 	# check if the folder localhost contains fedoraXML
-	$host_path = &util::filename_cat($base_path, "localhost");
-	$xmlFile = &util::filename_cat($host_path, "fedora.xml");
+	$host_path = &FileUtils::filenameConcatenate($base_path, "localhost");
+	$xmlFile = &FileUtils::filenameConcatenate($host_path, "fedora.xml");
 	if(!-e $xmlFile) {
 	    # try putting gsdl in this folder, but still print a warning
@@ -405,5 +406,5 @@
     # 3. If there is already a gsdl.xml file in host_path, compare the string we
     # want to write with what is already in there. If they're the same, we can return
-    $xmlFile = &util::filename_cat($host_path, "gsdl.xml");
+    $xmlFile = &FileUtils::filenameConcatenate($host_path, "gsdl.xml");
     if(-e $xmlFile) {
 	# such a file exists, so read the contents
@@ -428,5 +429,5 @@
     # a. First stop the fedora server
     my $script_ext = ($ENV{'GSDLOS'} =~ m/^windows/) ? ".bat" : ".sh";
-    my $stop_tomcat = &util::filename_cat($fedora_home, "tomcat", "bin", "shutdown".$script_ext);
+    my $stop_tomcat = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "bin", "shutdown".$script_ext);
     # execute the command 
     $! = 0; # does this initialise the return value?
@@ -447,5 +448,5 @@
 
     # c. Restart the fedora server
-    my $start_tomcat = &util::filename_cat($fedora_home, "tomcat", "bin", "startup".$script_ext);
+    my $start_tomcat = &FileUtils::filenameConcatenate($fedora_home, "tomcat", "bin", "startup".$script_ext);
     $! = 0;
     $status = system($start_tomcat);
@@ -458,4 +459,7 @@
     $ENV{'CATALINA_HOME'} = $gs_catalina_home if defined $gs_catalina_home;
     
+    # the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+    &util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
+
     # Starting up the Fedora server takes a long time. We need to wait for the server to be
     # ready before import can continue, because g2f-import relies on an up-and-running Fedora
Index: /main/trunk/greenstone2/perllib/giget.pm
===================================================================
--- /main/trunk/greenstone2/perllib/giget.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/giget.pm	(revision 28560)
@@ -80,4 +80,8 @@
     
     if ((!-e $downloadto_fname) || (-z $downloadto_fname)) {
+
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
+
 	my $cmd = "wget -nv -T 10 -nc -U \"Mozilla\" -O \"$downloadto_fname\" \"$full_url\"";
 ##	print STDERR "*** wget cmd:\n $cmd\n";
Index: /main/trunk/greenstone2/perllib/plugins/LOMPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/LOMPlugin.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/plugins/LOMPlugin.pm	(revision 28560)
@@ -37,4 +37,5 @@
 use MetadataRead;
 use util;
+use FileUtils;
 use XMLParser;
 use Cwd;
@@ -582,5 +583,5 @@
     my $output_dir = $self->{'output_dir'};
 
-    $output_dir = &util::filename_cat($output_dir,"_gsdldown.all");
+    $output_dir = &FileUtils::filenameConcatenate($output_dir,"_gsdldown.all");
 
     if (! -d $output_dir) {
@@ -596,9 +597,9 @@
     $file_url .= "index.html" if ($file_url =~ m/\/$/);
 
-    my $full_file_url = &util::filename_cat($output_dir,$file_url);
+    my $full_file_url = &FileUtils::filenameConcatenate($output_dir,$file_url);
     # the path to srcdoc will be used later in extrametadata to associate
     # the lom metadata with the document. Needs to be relative to current
     # directory.
-    my $srcdoc_path = &util::filename_cat("_gsdldown.all", $file_url);
+    my $srcdoc_path = &FileUtils::filenameConcatenate("_gsdldown.all", $file_url);
     my $check_timestamp = $self->{'check_timestamp'};
     my $status;
@@ -628,5 +629,7 @@
 	}
 	##print STDERR "**** wget = $wget_cmd\n";
-
+	
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 	
 	$status = system($wget_cmd);
Index: /main/trunk/greenstone2/perllib/plugins/MediaWikiPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/MediaWikiPlugin.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/plugins/MediaWikiPlugin.pm	(revision 28560)
@@ -35,4 +35,6 @@
 use HTMLPlugin;
 use unicode;
+use util;
+use FileUtils;
 
 use strict; # every perl program should have this!
@@ -218,4 +220,8 @@
 	    $css_files[$css_file_count++] = $2 if defined $2;
 	}
+
+	# Set the env for wget once, outside the for loop
+	# the wget binary is dependent on the gnomelib_env (particularly lib/libiconv2.dylib) being set, particularly on Mac Lions (android too?)
+	&util::set_gnomelib_env(); # this will set the gnomelib env once for each subshell launched, by first checking if GEXTGNOME is not already set
 	    
 	# download the stylesheets if we haven't downloaded them yet
@@ -238,5 +244,5 @@
 	    $css_file =~ s/\?(.+)$//isg;  
 	   
-            my $css_file_path = &util::filename_cat($base_dir, $css_file);	    
+            my $css_file_path = &FileUtils::filenameConcatenate($base_dir, $css_file);	    
 	    
 	    # do nothing if we have already downloaded the css files
@@ -251,5 +257,5 @@
 		mkdir($path_check) if (! -d $path_check );
 	     }
-	     
+
              # NOTE: wget needs configuration to directly access Internet
              # These files should already downloaded if we used the MediaWikiDownload             
@@ -293,5 +299,5 @@
             $style_dir =~ s/import$/style/;
             $css_file =~ m/(.*)\/(.*)$/;
-            $style_dir = &util::filename_cat($style_dir, $2);            
+            $style_dir = &FileUtils::filenameConcatenate($style_dir, $2);            
             
             if(open(OUTPUT, ">$style_dir")){	
@@ -477,5 +483,5 @@
         my $macro_path = $base_dir;
         $macro_path =~ s/import$/macros/;    	
-    	my $extradm_file = &util::filename_cat($macro_path, "extra.dm");        
+    	my $extradm_file = &FileUtils::filenameConcatenate($macro_path, "extra.dm");        
         
         my $extra_dm = "";
@@ -644,5 +650,5 @@
     my $self = shift(@_);
 
-  my $about_macro_file = &util::filename_cat($ENV{'GSDLHOME'}, "macros", "about.dm");
+  my $about_macro_file = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "macros", "about.dm");
   my $about_page_content = "";
   if (open(INPUT, "<$about_macro_file")){
Index: /main/trunk/greenstone2/perllib/util.pm
===================================================================
--- /main/trunk/greenstone2/perllib/util.pm	(revision 28559)
+++ /main/trunk/greenstone2/perllib/util.pm	(revision 28560)
@@ -1650,4 +1650,77 @@
 }
 
+# Sets the gnomelib_env. Based on the logic in wvware.pl which can perhaps be replaced with a call to this function in future
+sub set_gnomelib_env
+{
+    ## SET THE ENVIRONMENT AS DONE IN SETUP.BASH/BAT OF GNOME-LIB
+    # Though this is only needed for darwin Lion at this point (and android, though that is untested)
+
+    my $env_vars="";
+
+    my $libext = "so";
+    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
+	#return $env_vars;
+	return;
+    } elsif ($ENV{'GSDLOS'} =~ m/^darwin$/i) {
+	$libext = "dylib";
+    }
+
+    if (!defined $ENV{'GEXTGNOME'}) {
+        ##print STDERR "@@@ Setting GEXTGNOME env\n";
+
+	my $gnome_dir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"ext","gnome-lib-minimal");
+
+	if(! -d $gnome_dir) {
+	    $gnome_dir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"ext","gnome-lib");
+
+	    if(! -d $gnome_dir) {
+		$gnome_dir = "";
+	    }
+	}
+    
+	# now set other the related env vars, 
+	# IF we've found the gnome-lib dir installed in the ext folder	
+
+	if ($gnome_dir ne "" && -f &FileUtils::filenameConcatenate($gnome_dir, $ENV{'GSDLOS'}, "lib", "libiconv.$libext")) {
+	    $ENV{'GEXTGNOME'} = $gnome_dir;
+	    $ENV{'GEXTGNOME_INSTALLED'}=&FileUtils::filenameConcatenate($ENV{'GEXTGNOME'}, $ENV{'GSDLOS'});
+	   
+	    my $gnomelib_bin = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "bin");
+	    if(-d $gnomelib_bin) { # no bin subfolder in GS binary's cutdown gnome-lib-minimal folder
+		&util::envvar_prepend("PATH", $gnomelib_bin);
+		#$env_vars = "export PATH=".$ENV{'PATH'}.";";
+	    }
+
+	    # util's prepend will create LD/DYLD_LIB_PATH if it doesn't exist yet
+	    my $gextlib = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "lib");
+
+	    if($ENV{'GSDLOS'} eq "linux") {
+		&util::envvar_prepend("LD_LIBRARY_PATH", $gextlib);
+		#$env_vars .= "export LD_LIBRARY_PATH=".$ENV{'LD_LIBRARY_PATH'};
+	    } 
+	    elsif ($ENV{'GSDLOS'} eq "darwin") {
+		#&util::envvar_prepend("DYLD_LIBRARY_PATH", $gextlib);
+		&util::envvar_prepend("DYLD_FALLBACK_LIBRARY_PATH", $gextlib);
+		#$env_vars .= "export DYLD_FALLBACK_LIBRARY_PATH=".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'};
+	    }
+	}
+	
+	# Above largely mimics the setup.bash of the gnome-lib-minimal.
+	# Not doing the devel-srcpack that gnome-lib-minimal's setup.bash used to set
+	# Not exporting GSDLEXTS variable either
+    }
+
+#    print STDERR "@@@@@ GEXTGNOME: ".$ENV{'GEXTGNOME'}."\n\tINSTALL".$ENV{'GEXTGNOME_INSTALLED'}."\n";
+#    print STDERR "\tPATH".$ENV{'PATH'}."\n";
+#    print STDERR "\tLD_LIB_PATH".$ENV{'LD_LIBRARY_PATH'}."\n" if $ENV{'LD_LIBRARY_PATH};
+#    print STDERR "\tDYLD_FALLBACK_LIB_PATH".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'}."\n" if $ENV{'DYLD_FALLBACK_LIBRARY_PATH};
+
+    # if no GEXTGNOME, maybe users didn't need gnome-lib to run gnomelib/libiconv dependent binaries like hashfile, suffix, wget 
+    # (wvware is launched in a gnomelib env from its own script, but could possibly go through this script in future)
+
+    #return $env_vars; #print STDOUT $env_vars;
+}
+
+
 
 ## @function augmentINC()
