Index: main/trunk/greenstone2/perllib/mgbuilder.pm
===================================================================
--- main/trunk/greenstone2/perllib/mgbuilder.pm	(revision 29176)
+++ main/trunk/greenstone2/perllib/mgbuilder.pm	(revision 29328)
@@ -158,6 +158,9 @@
     }
     else {
-	if (!-e "$mg_passes_exe" || 
-	    !open($handle, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T1 -M $maxnumeric $osextra")) {
+	my $mgpasses_cmd = "mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T1 -M $maxnumeric $osextra";	
+	#print STDERR "**** mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T1 -M $maxnumeric $osextra\n\n";
+	print $outhandle "\ncmd: $mgpasses_cmd\n" if ($self->{'verbosity'} >= 4);
+
+	if (!-e "$mg_passes_exe" || !open($handle, "| $mgpasses_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'>\n</Stage>\n" if $self->{'gli'};
 	    die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
@@ -196,9 +199,11 @@
     if (!$self->{'debug'}) {
 	print $outhandle "\n    creating the compression dictionary\n"  if ($self->{'verbosity'} >= 1);
+	my $compdict_cmd = "mg_compression_dict$exe -f \"$fulltextprefix\" -S\ -H -2 -k 5120 $osextra";
+	print $outhandle "\ncmd: $compdict_cmd\n" if ($self->{'verbosity'} >= 4);
 	print STDERR "<Phase name='CreatingCompress'/>\n" if $self->{'gli'};
 	if (!-e "$mg_compression_dict_exe") {
 	    die "mgbuilder::compress_text - couldn't run $mg_compression_dict_exe\n";
 	}
-	my $comp_dict_status = system ("mg_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
+	my $comp_dict_status = system ($compdict_cmd);
 	if($comp_dict_status != 0) {
 	    print $outhandle "\nmgbuilder::compress_text - Warning: there's no compressed text\n";
@@ -209,6 +214,8 @@
 
 	# -b $maxdocsize sets the maximum document size to be 12 meg
-	if (!-e "$mg_passes_exe" || 
-	    !open ($handle, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T2 -M $maxnumeric $osextra")) {
+	my $mgpasses_cmd = "mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T2 -M $maxnumeric $osextra" ;
+	print $outhandle "\ncmd: $mgpasses_cmd\n" if ($self->{'verbosity'} >= 4);
+
+	if (!-e "$mg_passes_exe" || !open ($handle, "| $mgpasses_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 	    die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
@@ -415,7 +422,9 @@
     }
     else {
-	if (!-e "$mg_passes_exe" || 
-	    !open($handle, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
-		   "-$index_level -m 32 -s 0 -G -t 10 -N1 -M $maxnumeric $osextra")) {
+        my $mgpasses_cmd = "mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
+		   "-$index_level -m 32 -s 0 -G -t 10 -N1 -M $maxnumeric $osextra";
+    	print $outhandle "\ncmd: $mgpasses_cmd\n" if ($self->{'verbosity'} >= 4);
+
+	if (!-e "$mg_passes_exe" || !open($handle, "| $mgpasses_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 	    die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
@@ -466,7 +475,8 @@
 	}
 
-	if (!-e "$mg_passes_exe" || 
-	    !open ($handle, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
-		   "-$index_level -c 3 -G -t 10 -N2 -M $maxnumeric $osextra")) {
+        my $mgpasses_cmd = "mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
+            "-$index_level -c 3 -G -t 10 -N2 -M $maxnumeric $osextra";
+    	print $outhandle "\ncmd: $mgpasses_cmd\n" if ($self->{'verbosity'} >= 4);
+	if (!-e "$mg_passes_exe" || !open ($handle, "| $mgpasses_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 	    die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
@@ -514,4 +524,7 @@
 	# create 'on-disk' stemmed dictionary
 	print $outhandle "\n    creating 'on-disk' stemmed dictionary\n"  if ($self->{'verbosity'} >= 1);
+        my $invdict_cmd = "mg_invf_dict$exe -f \"$fullindexprefix\" $osextra";
+	print $outhandle "\ncmd: $invdict_cmd\n" if ($self->{'verbosity'} >= 4);
+
 	print STDERR "<Phase name='CreateStemmedDic'/>\n" if $self->{'gli'};
 	if (!-e "$mg_invf_dict_exe") {
@@ -519,5 +532,5 @@
 	    die "mgbuilder::build_index - couldn't run $mg_invf_dict_exe\n";
 	}
-	my $invdict_status = system ("mg_invf_dict$exe -f \"$fullindexprefix\" $osextra");
+	my $invdict_status = system ($invdict_cmd);
 	# check that it worked - if not, don't carry on
 	if ($invdict_status !=0) {
@@ -550,14 +563,21 @@
 	# same as above: generate all the stem idexes. But don't bother stemming if
 	# casefolding failed, and don't try generating indexes for both if stemming failed
-	my $stem_index_status = system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
+        my $stemindex_cmd = "mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra";
+	print $outhandle "\ncmd: $stemindex_cmd\n" if ($self->{'verbosity'} >= 4);
+
+        my $stem_index_status = system ($stemindex_cmd);
 	if($stem_index_status != 0) {
 	    print $outhandle "\nCase folding failed: mg_stem_idx exit status $stem_index_status\n" if ($self->{'verbosity'} >= 4);
 	} else {
-	    $stem_index_status = system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
+	    $stemindex_cmd = "mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra";
+	    print $outhandle "\ncmd: $stemindex_cmd\n" if ($self->{'verbosity'} >= 4);
+	    $stem_index_status = system ($stemindex_cmd);
 
 	    if($stem_index_status != 0) {
 		print $outhandle "\nStemming failed: mg_stem_idx exit status $stem_index_status\n" if ($self->{'verbosity'} >= 4);
 	    } else {
-		$stem_index_status = system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
+		$stemindex_cmd = "mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra";
+		print $outhandle "\ncmd: $stemindex_cmd\n" if ($self->{'verbosity'} >= 4);
+		$stem_index_status = system ($stemindex_cmd);
 
 		if($stem_index_status != 0) {
@@ -596,6 +616,10 @@
     my $collect_tail = &util::get_dirsep_tail($self->{'collection'});
     my $input_file = &FileUtils::filenameConcatenate("text", $collect_tail);
-    if (!-e "$mgstat_exe" || !open (PIPEIN, "mgstat$exe -d \"$self->{'build_dir'}\" -f \"$input_file\" |")) {
-	my $outhandle = $self->{'outhandle'};
+
+    my $mgstat_cmd = "mgstat$exe -d \"$self->{'build_dir'}\" -f \"$input_file\"";
+    my $outhandle = $self->{'outhandle'};
+    print $outhandle "\ncmd: $mgstat_cmd\n" if ($self->{'verbosity'} >= 4);
+    if (!-e "$mgstat_exe" || !open (PIPEIN, "$mgstat_cmd |")) {
+
 	print $outhandle "Warning: Couldn't open pipe to $mgstat_exe to get additional stats\n";
     } else {
Index: main/trunk/greenstone2/perllib/mgppbuilder.pm
===================================================================
--- main/trunk/greenstone2/perllib/mgppbuilder.pm	(revision 29176)
+++ main/trunk/greenstone2/perllib/mgppbuilder.pm	(revision 29328)
@@ -208,6 +208,7 @@
     }
     else {
-	if (!-e "$mgpp_passes_exe" || 
-	    !open($handle, "| mgpp_passes$exe  -M $maxnumeric $mgpp_passes_sections -f \"$fulltextprefix\" -T1 $osextra")) {
+	my $mgpp_passes_cmd = "mgpp_passes$exe  -M $maxnumeric $mgpp_passes_sections -f \"$fulltextprefix\" -T1 $osextra";
+	print $outhandle "\ncmd: $mgpp_passes_cmd\n"  if ($self->{'verbosity'} >= 4);
+	if (!-e "$mgpp_passes_exe" || !open($handle, "| $mgpp_passes_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'>\n</Stage>\n" if $self->{'gli'};
 	    die "mgppbuilder::compress_text - couldn't run $mgpp_passes_exe\n";
@@ -242,5 +243,7 @@
     # note: these options are left over from mg version
     if (!$self->{'debug'}) {
+	my $compdict_cmd = "mgpp_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra";	
 	print $outhandle "\n    creating the compression dictionary\n"  if ($self->{'verbosity'} >= 1);
+	print $outhandle "\ncmd: $compdict_cmd\n"  if ($self->{'verbosity'} >= 4);
 	print STDERR "<Phase name='CreatingCompress'/>\n" if $self->{'gli'};
 	if (!-e "$mgpp_compression_dict_exe") {
@@ -248,5 +251,5 @@
 	    die "mgppbuilder::compress_text - couldn't run $mgpp_compression_dict_exe\n";
 	}
-	my $comp_dict_status = system ("mgpp_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
+	my $comp_dict_status = system ($compdict_cmd);
 	if($comp_dict_status != 0) {
 	    print $outhandle "\nmgppbuilder::compress_text - Warning: there's no compressed text\n";
@@ -257,6 +260,8 @@
 
 	if (!$self->{'debug'}) {
-	    if (!-e "$mgpp_passes_exe" || 
-		!open ($handle, "| mgpp_passes$exe  -M $maxnumeric $mgpp_passes_sections -f \"$fulltextprefix\" -T2 $osextra")) {
+	    my $mgpp_passes_cmd = "mgpp_passes$exe -M $maxnumeric $mgpp_passes_sections -f \"$fulltextprefix\" -T2 $osextra";
+	    print $outhandle "\ncmd: $mgpp_passes_cmd\n"  if ($self->{'verbosity'} >= 4);
+
+	    if (!-e "$mgpp_passes_exe" || !open ($handle, "| $mgpp_passes_cmd")) {
 		print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 		die "mgppbuilder::compress_text - couldn't run $mgpp_passes_exe\n";
@@ -474,6 +479,7 @@
     }
     else {
-	if (!-e "$mgpp_passes_exe" || 
-	    !open($handle, "| mgpp_passes$exe -M $maxnumeric $mgpp_passes_sections -f \"$fullindexprefix\" -I1 $osextra")) {
+        my $mgpp_passes_cmd = "mgpp_passes$exe -M $maxnumeric $mgpp_passes_sections -f \"$fullindexprefix\" -I1 $osextra";
+    	print $outhandle "\ncmd: $mgpp_passes_cmd\n"  if ($self->{'verbosity'} >= 4);
+	if (!-e "$mgpp_passes_exe" || !open($handle, "| $mgpp_passes_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 	    die "mgppbuilder::build_index - couldn't run $mgpp_passes_exe\n";
@@ -530,7 +536,8 @@
 	    
 	}
-	
-	if (!-e "$mgpp_passes_exe" || 
-	    !open ($handle, "| mgpp_passes$exe -M $maxnumeric $mgpp_passes_sections -f \"$fullindexprefix\" -I2 $osextra")) {
+
+	my $mgpp_passes_cmd = "mgpp_passes$exe -M $maxnumeric $mgpp_passes_sections -f \"$fullindexprefix\" -I2 $osextra";
+    	print $outhandle "\ncmd: $mgpp_passes_cmd\n"  if ($self->{'verbosity'} >= 4);
+	if (!-e "$mgpp_passes_exe" || !open ($handle, "| $mgpp_passes_cmd")) {
 	    print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
 	    die "mgppbuilder::build_index - couldn't run $mgpp_passes_exe\n";
@@ -581,5 +588,7 @@
 	    die "mgppbuilder::build_index - couldn't run $mgpp_invf_dict_exe\n";
 	}
-	my $invdict_status = system ("mgpp_invf_dict$exe -f \"$fullindexprefix\" $osextra" );
+        my $invdict_cmd = "mgpp_invf_dict$exe -f \"$fullindexprefix\" $osextra";
+	print $outhandle "\ncmd: $invdict_cmd\n"  if ($self->{'verbosity'} >= 4);
+        my $invdict_status = system ($invdict_cmd);
 	# check that it worked - if not, don't carry on
 	if ($invdict_status !=0) {
@@ -600,6 +609,8 @@
 	my $accent_folding_enabled = 1;
 	if ($self->{'accentfold'}) {
+	    my $accentfold_cmd = "mgpp_stem_idx$exe -b 4096 -s4 -f \"$fullindexprefix\" $osextra";
+	    print $outhandle "\ncmd: $accentfold_cmd\n"  if ($self->{'verbosity'} >= 4);
 	    # the first time we do this, we test for accent folding enabled
-	    my $accent_status = system ("mgpp_stem_idx$exe -b 4096 -s4 -f \"$fullindexprefix\" $osextra");
+	    my $accent_status = system ($accentfold_cmd);
 	    if ($accent_status == 2) {
 		# accent folding has not been enabled in mgpp
@@ -614,5 +625,7 @@
 	}
 	if ($self->{'casefold'}) {
-	    my $casefold_status = system ("mgpp_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
+	    my $casefold_cmd = "mgpp_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra";
+	    print $outhandle "\ncmd: $casefold_cmd\n"  if ($self->{'verbosity'} >= 4);
+	    my $casefold_status = system ($casefold_cmd);
 	    if ($casefold_status != 0) {
 		print $outhandle "\nCase folding failed: mgpp_stem_idx exit status $casefold_status\n" if ($self->{'verbosity'} >= 4);
@@ -622,5 +635,7 @@
 	    
 	    elsif ($accent_folding_enabled && $self->{'accentfold'}) {
-		my $status = system ("mgpp_stem_idx$exe -b 4096 -s5 -f \"$fullindexprefix\" $osextra");
+	        my $accent_casefold_cmd = "mgpp_stem_idx$exe -b 4096 -s5 -f \"$fullindexprefix\" $osextra";
+	        print $outhandle "\ncmd: $accent_casefold_cmd\n"  if ($self->{'verbosity'} >= 4);
+		my $status = system ($accent_casefold_cmd);
 		if($status != 0) {
 		    print $outhandle "\nAccent folding (with casefolding) failed: mgpp_stem_idx exit status $status\n" if ($self->{'verbosity'} >= 4);
@@ -631,5 +646,7 @@
 	}
 	if ($self->{'stem'}) {
-	    my $stem_status = system ("mgpp_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
+            my $stem_cmd = "mgpp_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra";
+            print $outhandle "\ncmd: $stem_cmd\n"  if ($self->{'verbosity'} >= 4);
+	    my $stem_status = system ($stem_cmd);
 	    if ($stem_status != 0) {
 		print $outhandle "\nStemming failed: mgpp_stem_idx exit status $stem_status\n" if ($self->{'verbosity'} >= 4);
@@ -638,5 +655,7 @@
 	    }
 	    elsif ($accent_folding_enabled && $self->{'accentfold'}) {
-		my $status = system ("mgpp_stem_idx$exe -b 4096 -s6 -f \"$fullindexprefix\" $osextra");
+                my $accent_stem_cmd = "mgpp_stem_idx$exe -b 4096 -s6 -f \"$fullindexprefix\" $osextra";
+                print $outhandle "\ncmd: $accent_stem_cmd\n"  if ($self->{'verbosity'} >= 4);
+	        my $status = system ($accent_stem_cmd);
 		if($status != 0) {
 		    print $outhandle "\nAccent folding (with stemming) failed: mgpp_stem_idx exit status $status\n" if ($self->{'verbosity'} >= 4);
@@ -647,5 +666,7 @@
 	}
 	if ($self->{'casefold'} && $self->{'stem'}) {
-	    my $case_and_stem_status = system ("mgpp_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
+            my $case_stem_cmd = "mgpp_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra";
+            print $outhandle "\ncmd: $case_stem_cmd\n"  if ($self->{'verbosity'} >= 4);
+	    my $case_and_stem_status = system ($case_stem_cmd);
 	    if ($case_and_stem_status != 0) {
 		print $outhandle "\nCasefolding and stemming failed: mgpp_stem_idx exit status $case_and_stem_status\n" if ($self->{'verbosity'} >= 4);
@@ -655,5 +676,7 @@
 	    }
 	    elsif ($accent_folding_enabled && $self->{'accentfold'}) {
-		my $status = system ("mgpp_stem_idx$exe -b 4096 -s7 -f \"$fullindexprefix\" $osextra");
+		my $accent_case_stem_cmd = "mgpp_stem_idx$exe -b 4096 -s7 -f \"$fullindexprefix\" $osextra";
+                print $outhandle "\ncmd: $accent_case_stem_cmd\n"  if ($self->{'verbosity'} >= 4);
+		my $status = system ($accent_case_stem_cmd);
 		if($status != 0) {
 		    print $outhandle "\nAccent folding (with stemming and casefolding) failed: mgpp_stem_idx exit status $status\n" if ($self->{'verbosity'} >= 4);
