Index: other-projects/nightly-tasks/diffcol/trunk/task.pl
===================================================================
--- other-projects/nightly-tasks/diffcol/trunk/task.pl	(revision 27628)
+++ other-projects/nightly-tasks/diffcol/trunk/task.pl	(revision 27629)
@@ -66,23 +66,23 @@
 #check key environment vars are set
 if(!defined $ENV{'UPLOAD_DIR'}) {
-    print STDOUT "Please set a UPLOAD_DIR for the test in an environment.sh file\n";
+    print STDERR "Please set a UPLOAD_DIR for the test in an environment.sh file\n";
     #return 1;
 }
 if(!defined $ENV{'DATA_DIR'}) {
-    print STDOUT "Please set a DATA_DIR for the test in an environment.sh file\n";
+    print STDERR "Please set a DATA_DIR for the test in an environment.sh file\n";
     #return 1;
 }
 if(!defined $ENV{'MONITOR_EMAIL'}) {
-    print STDOUT "Please set a MONITOR_EMAIL for the test in an environment.sh file\n";
+    print STDERR "Please set a MONITOR_EMAIL for the test in an environment.sh file\n";
     #return 1;
 }
 
 if($ENV{'DATA_DIR'} eq "/") {
-    print STDOUT "DATA_DIR should not be the fs root\n";
+    print STDERR "DATA_DIR should not be the fs root\n";
     #return 1;
 } 
 
-print STDOUT "DATA_DIR: ".$ENV{'DATA_DIR'}."\n";
-print STDOUT "UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n";
+print STDERR "DATA_DIR: ".$ENV{'DATA_DIR'}."\n";
+print STDERR "UPLOAD_DIR: ".$ENV{'UPLOAD_DIR'}."\n";
 
 #create an id for this test
@@ -94,5 +94,5 @@
 my $dateid="$year-$mon-$mday"; #my $dateid=($year+1900)."-".($mon+1)."-$mday";
 
-print STDOUT "Starting test '$dateid'\n";
+print STDERR "Starting test '$dateid'\n";
 
 
@@ -100,5 +100,4 @@
 $ENV{'CLASSPATH'} = "";
 my $jar_lib_path = $ENV{'TASK_HOME'}.$sep."lib";
-##print STDERR "@@@ $jar_lib_path\n";
 my @files = <$jar_lib_path/*.jar>; # /full/path/to/diffcol/lib/*jar
 foreach my $file (@files) {
@@ -122,5 +121,5 @@
 
 if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) {
-    print STDOUT "Found existing Greenstone home, will use that instead\n";
+    print STDERR "Found existing Greenstone home, will use that instead\n";
     $greenstone_home=$ENV{'GSDLHOME'};
 } else {
@@ -172,8 +171,8 @@
 
     # http://perldoc.perl.org/File/Path.html
-    print STDOUT "cleaning up previous tests\n";
+    print STDERR "cleaning up previous tests\n";
     &File::Path::remove_tree($ENV{'DATA_DIR'});
 
-    print STDOUT "creating the data dir\n";
+    print STDERR "creating the data dir\n";
     &File::Path::make_path($ENV{'DATA_DIR'}); # works like mkdir -p
 
@@ -182,5 +181,5 @@
     # use existing compiled-up greenstone installation, if a GSDLHOME set
     if(defined $ENV{'GSDL3SRCHOME'} || defined $ENV{'GSDLHOME'}) {
-	print STDOUT "Found existing Greenstone home, will use that instead";
+	print STDERR "Found existing Greenstone home, will use that instead";
 	return;
     }
@@ -189,5 +188,5 @@
 
     #svn checkout of main gsdl directory                                       
-    print STDOUT "checkout $gsdl:\n";
+    print STDERR "checkout $gsdl:\n";
     my $cmd = "svn co ".$ENV{'SVN_OPT_REV'}." http://svn.greenstone.org/main/trunk/greenstone2 $gsdl";
     ##print STDERR "Checkout CMD: $cmd\n";
@@ -196,5 +195,5 @@
     # http://stackoverflow.com/questions/758611/how-to-flush-output-in-backticks-in-perl?rq=1
     my $status = system "$cmd"; #my $status = `$cmd`;
-    print STDOUT "done\n";
+    print STDERR "done\n";
 
     ##print STDERR "$ENV{'DATA_DIR'}$sep$gsdl\n";
@@ -207,5 +206,5 @@
     if(!$isWin) {
 
-	print STDOUT "setting up gnome-lib-minimal for compilation\n";
+	print STDERR "setting up gnome-lib-minimal for compilation\n";
 
 	# To get gnome-lib, need to determine bit architecture of the linux/darwin
@@ -241,7 +240,5 @@
 	# http://ubuntuforums.org/showthread.php?t=1932504 linking /bin/sh to bash instead of dash 
 	
-#	$cmd = "/bin/bash \"source devel.bash && cd ../.. && ./configure --enable-apache httpd && make && make install\"";
 #	$cmd = "bash -c \"source ./devel.bash && cd ../.. && ./configure --enable-apache-httpd && make && make install\"";
-
 	$cmd = "bash -c \"";	
 
@@ -297,9 +294,9 @@
 
     # get svn info
-    print STDOUT "getting svn info: $xmlout\n";
+    print STDERR "getting svn info: $xmlout\n";
     print $xml_fh "<svn-info>\n";
     run_and_print_cmd("svn info", $xml_fh);
     print $xml_fh "</svn-info>\n";
-    print STDOUT "done\n";
+    print STDERR "done\n";
 
     #make two copies of the model-collect directory in gsdl
@@ -308,5 +305,5 @@
     
     #copy the model collections to the collect folder to be rebuilt
-    print STDOUT "installing test collections and model collections to new $gsdl installation... ";
+    print STDERR "installing test collections and model collections to new $gsdl installation... ";
 	
     #clean up
@@ -324,5 +321,5 @@
     &copy_recursively("collect", "model-collect"); # copy contents across
     
-    print STDOUT "done\n";    
+    print STDERR "done\n";    
 	
 
@@ -331,5 +328,5 @@
     for my $collection (readdir $collect_handle) {
 	next if ($collection eq "." || $collection eq "..");
-	next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT
+	#next if ($collection ne "Small-HTML"); ## TEMPORARY, FOR TESTING THIS SCRIPT
 
 	#escape the filename (in case of space)
@@ -345,25 +342,19 @@
 # although it means that duplicate documents contained in the collection are
 # no longer detected automatically."
-	print STDOUT "$collection - Importing:\n";
+	print STDERR "$collection - Importing:\n";
 	print $xml_fh "<import>\n";
-#	$cmd = "import.pl -OIDtype hash_on_full_filename $collection -removeold";
-#	&run_build_script($cmd);
-	$cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && import.pl -OIDtype hash_on_full_filename -removeold $collection\"";
-	system($cmd);
+	&run_build_script("import.pl -OIDtype hash_on_full_filename $collection -removeold");
 	print $xml_fh "</import>\n";
-	print STDOUT "done\n";	
+	print STDERR "done\n";	
 
 	#build
-	print STDOUT "$collection - Building:\n";
+	print STDERR "$collection - Building:\n";
 	print $xml_fh "<build>\n";
-#	$cmd = "buildcol.pl $collection -removeold";
-#	&run_build_script($cmd);
-	$cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && buildcol.pl -removeold $collection\"";
-	system($cmd);
+	&run_build_script("buildcol.pl $collection -removeold");
 	print $xml_fh "</build>\n";
-	print STDOUT "done\n";
+	print STDERR "done\n";
 	
 	#rename the intermediate 'building' directory 'index'
-	print STDOUT "$collection - Move \"building\" to \"index\"... ";
+	print STDERR "$collection - Move \"building\" to \"index\"... ";
 	my $index = &filename_concat("collect", $collection, "index");
 	my $building = &filename_concat("collect", $collection, "building");
@@ -371,8 +362,8 @@
 	# Renaming Directories, http://www.perlmonks.org/?node_id=177421
 	move($building, $index) or die "copy failed: $!"; # File::Copy::move
-	print STDOUT "done\n";
+	print STDERR "done\n";
 
 	#diffcol
-	print STDOUT "$collection - Diffing:\n";
+	print STDERR "$collection - Diffing:\n";
 	my $diffcol_dir = &filename_concat($ENV{'TASK_HOME'},"diffcol");
 	$cmd = "./diffcol.pl -output xml -verbosity 10 $collection";	
@@ -380,5 +371,5 @@
 
 	chdir($greenstone_home); # this is actually where we are
-	print STDOUT "done\n";
+	print STDERR "done\n";
 	print $xml_fh "</collection-test>\n";
     }
@@ -388,5 +379,5 @@
     close($xml_fh);
 
-    print STDOUT "done\n";
+    print STDERR "done\n";
 }
 
@@ -421,5 +412,6 @@
     }
 
-    return &run_and_print_cmd($cmd, $fh);
+    return system($cmd); 
+    #return &run_and_print_cmd($cmd, $fh); # doesn't work on cmds chained with bash -c
 }
 
@@ -497,14 +489,14 @@
 
     # make a summarised Xml report
-    print STDOUT "Summarizing the xml report... ";
+    print STDERR "Summarizing the xml report... ";
     my $cmd = "java org.apache.xalan.xslt.Process -IN $xmlout -XSL $ENV{'TASK_HOME'}/xsl/xml-report.xsl -OUT $ENV{'DATA_DIR'}/report-$dateid.xml";
     my $status = system($cmd);
-    print STDOUT "done\n";
+    print STDERR "done\n";
 
     # make a summarised HTMl report
-    print STDOUT "Creating an html summary report... ";
+    print STDERR "Creating an html summary report... ";
     $cmd = "java org.apache.xalan.xslt.Process -IN $ENV{'DATA_DIR'}/report-$dateid.xml -XSL $ENV{'TASK_HOME'}/xsl/html-report.xsl -OUT $ENV{'DATA_DIR'}/report-$dateid.html";
     $status = system($cmd);
-    print STDOUT "done\n";
+    print STDERR "done\n";
 }
 
@@ -524,5 +516,5 @@
     closedir $dh;
 
-    print STDOUT "Finished uploading\n";
+    print STDERR "Finished uploading\n";
 }
 
@@ -533,10 +525,10 @@
 {
     # email out with report attached, if the tests failed                                                      
-    print STDOUT "Checking if successful... \n";
+    print STDERR "Checking if successful... \n";
     my $cmd = "java org.apache.xalan.xslt.Process -IN $xmlout -XSL $ENV{'TASK_HOME'}/xsl/passed-or-not.xsl";
     #my $result = system($cmd);
     my $result = `$cmd`;
 
-    print STDOUT "result: $result\n";
+    print STDERR "result: $result\n";
 
     if($result ne "yes") {
@@ -570,8 +562,8 @@
 	system($cmd); #	&run_and_print_cmd($cmd);
 
-	print STDOUT "Sent mail with report attached.\n";
+	print STDERR "Sent mail with report attached.\n";
     } else {
 	print STDERR "********************************************\n";
-	print STDOUT "Tests were successful. Not sending mail.\n";
+	print STDERR "Tests were successful. Not sending mail.\n";
 	print STDERR "********************************************\n";
     }
