Index: main/trunk/greenstone2/perllib/servercontrol.pm
===================================================================
--- main/trunk/greenstone2/perllib/servercontrol.pm	(revision 31513)
+++ main/trunk/greenstone2/perllib/servercontrol.pm	(revision 31514)
@@ -140,7 +140,6 @@
 
 	my $wget_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget");
-	my $tmpfilename = &util::get_tmp_filename(".html", 1); # random file name with html extension in timestamped-tmpdir location (2nd param=1) 
-															# wherein we'll store the HTML page retrieved by wget
-		
+	my $tmpfilename = &util::get_tmp_filename(".html"); # random file name with html extension in tmp location in which we'll store the HTML page retrieved by wget
+	
 	# https://www.gnu.org/software/wget/manual/wget.html
 	# output-document set to - (STDOUT), so page is streamed to STDOUT
@@ -154,7 +153,18 @@
 	
 	##print STDERR "@@@@ $wgetCommand\n";
-
-	my $response_content = `$wgetCommand`;
+	
+	my $response_content;
 	my $response_code = undef;
+	#my $response_content = `$wgetCommand`; # Dr Bainbridge advises against using backticks for running a process. If capturing std output, use open():
+	if (open(PIN, "$wgetCommand |")) {
+	    while (defined (my $perl_output_line = <PIN>)) {
+			$response_content = $response_content . $perl_output_line;
+	    }
+	    close(PIN);
+	} else {
+	    print STDERR "servercontrol.pm::config() failed to run $wgetCommand\n";
+	}
+	
+	
 	my @lines = split( /\n/, $response_content );
 	foreach my $line (@lines) {
@@ -182,5 +192,5 @@
 	    # server not running
 	    $self->print_msg("*** Server not running. $library_url$command\n", 3);
-		&util::rm_tmp_file($tmpfilename); # will also remove any randomly named tmp directories containing the file
+		&FileUtils::removeFiles($tmpfilename); # get rid of the ping response's temporary html file we downloaded
 	    return 0;
 	}
@@ -197,5 +207,5 @@
 		sysread(FIN, $resultstr, -s FIN);		
 		close(FIN);
-		&util::rm_tmp_file($tmpfilename); # will also remove any randomly named tmp directories containing the file
+		&FileUtils::removeFiles($tmpfilename); # get rid of the ping response's temporary html file we downloaded
 		
 		
Index: main/trunk/greenstone2/perllib/util.pm
===================================================================
--- main/trunk/greenstone2/perllib/util.pm	(revision 31513)
+++ main/trunk/greenstone2/perllib/util.pm	(revision 31514)
@@ -276,5 +276,4 @@
 {
     my $file_ext = shift(@_) || undef;
-	my $use_timestamped_tmp_dir = shift(@_) || 0; # else defaults to using super directory named "tmp"
 
     my $opt_dot_file_ext = "";
@@ -291,5 +290,5 @@
     }
 
-	my $tmpdir = $use_timestamped_tmp_dir ? &util::get_timestamped_tmp_folder() : &util::determine_tmp_dir(0);
+	my $tmpdir = &util::determine_tmp_dir(0);
 
     my $count = 1000;
@@ -387,18 +386,4 @@
 
     return $tmp_dirname;
-}
-
-sub rm_tmp_file
-{
-	my $tmpfilename = shift(@_);
-	
-	my $tmpdir = &util::get_parent_folder($tmpfilename);
-	
-	&FileUtils::removeFiles($tmpfilename);	
-	# if the containing folder is a randomly named temporary subdirectory, remove it
-	# but not if it is the temporary "tmp" super directory itself.
-	if($tmpdir !~ m@^tmp(\\|\/)*$@) {
-		&FileUtils::removeFilesRecursive($tmpdir);
-	}
 }
 
@@ -1298,5 +1283,5 @@
 		my $host = $uri->host;
 		#print STDERR "@@@@@ host: $host\n";
-		if($url =~ m/http:\/\/$host(\/)?$/) {
+		if($url =~ m/https?:\/\/$host(\/)?$/) {
 		    #if($url !~ m/http:\/\/$host:$portnumber(\/)?/ || $url =~ m/http:\/\/$host(\/)?$/) {
 		    # (if the URL does not contain the portnumber, OR if the port is implicitly 80 and)					
@@ -1338,6 +1323,6 @@
 	    while (defined (my $perl_output_line = <PIN>)) {
 
-		if($perl_output_line =~ m@http:\/\/(\S*)@) { # grab all the non-whitespace chars
-		    $url="http://".$1;
+		if($perl_output_line =~ m@(https?):\/\/(\S*)@) { # grab all the non-whitespace chars
+		    $url="$1://".$2; # preserve the http protocol #$url="http://".$1;
 		}
 	    }
@@ -1345,5 +1330,5 @@
 	} else {
 	    print STDERR "util::get_library_URL() failed to run $perl_command to work out library URL for $gs_mode\n";
-	}		
+	}
     }
     
