Index: trunk/gsdl/bin/script/gsConvert.pl
===================================================================
--- trunk/gsdl/bin/script/gsConvert.pl	(revision 2236)
+++ trunk/gsdl/bin/script/gsConvert.pl	(revision 2241)
@@ -91,10 +91,10 @@
     # Deduce filenames
     my ($tailname,$dirname,$suffix) 
-	= File::Basename::fileparse($input_filename,'\..+');
-    my $output_filestem = &util::filename_cat($dirname,"$tailname");
+	= File::Basename::fileparse($input_filename, "\\.[^\\.]+\$");
+    my $output_filestem = &util::filename_cat($dirname, "$tailname");
 
     if ($input_type eq "")
     {
-	$input_type = substr($suffix,1,length($suffix)-1);
+	$input_type = lc (substr($suffix,1,length($suffix)-1));
     }
     
@@ -138,5 +138,5 @@
 
 
-# Document-type conversion fucntions
+# Document-type conversion functions
 #
 # The following functions attempt to convert documents from their
@@ -219,5 +219,5 @@
     # Convert to text
     if (!$output_type || ($output_type =~ /text/i)) {
-	$success = any_to_text($input_filename, $output_filestem);
+	$success = &any_to_text($input_filename, $output_filestem);
 	if ($success) {
 	    return "text";
@@ -332,13 +332,68 @@
     my $wvWare = &util::filename_cat($ENV{'GSDLHOME'}, "bin", 
 				     $ENV{'GSDLOS'}, "wvWare");
-    $wvWare .= ".exe" if ($ENV{'GSDLOS'} =~ /^windows$/i);
-    return 0 unless (-e "$wvWare");
+
+    # don't include path on windows (to avoid having to play about
+    # with quoting when GSDLHOME might contain spaces) but assume
+    # that the PATH is set up correctly
+    $wvWare = "wvWare" if ($ENV{'GSDLOS'} =~ /^windows$/i);
 
     my $wv_conf = &util::filename_cat($ENV{'GSDLHOME'}, "packages", 
 				      "wv", "wvHtml.xml");
     
+    my $cmd = "";
+    if ($timeout) {$cmd = "ulimit -t $timeout;";}
+    $cmd .= "$wvWare --charset utf-8 --config \"$wv_conf\"";
+    $cmd .= " \"$input_filename\" > \"$output_filestem.html\"";
+    
+    # redirecting STDERR is a bad idea on windows 95/98
+    $cmd .= " 2> \"$output_filestem.err\""
+	if $ENV{'GSDLOS'} !~ /^windows$/i;
+
+    # execute the command
+    if (system($cmd)!=0)
+    {
+	print STDERR "Error executing wv converter: $!. Continuing...\n";
+    }
+
+    # Was the conversion successful?
+
+    if (-e "$output_filestem.html") {
+	open(TMP, "$output_filestem.html");
+	$line = <TMP>;
+	close(TMP);
+	if ($line && $line =~ /DOCTYPE HTML/) {
+	    &util::rm("$output_filestem.err") if -e "$output_filestem.err";
+	    return 1;
+	} else {
+	    # An error of some sort occurred
+	    &util::rm("$output_filestem.html");
+	    &util::rm("$output_filestem.err") if -e "$output_filestem.err";
+	}
+    }
+
+    return 0;
+}
+
+
+# Attempt to convert an RTF document to html with rtftohtml
+#
+# rtf2html isn't distributed with Greenstone because it is not 
+# distributed under the GPL.  If you know of a better solution,
+# please let me know.
+
+sub rtf_to_html {
+    my ($input_filename, $output_filestem) = @_;
+
+    # we'll give up already if using Windows
+    return 0 if $ENV{'GSDLOS'} =~ /^windows$/i;
+
+    # formulate the command
+    my $r_cmd = &util::filename_cat($ENV{'GSDLHOME'}, "packages", "unix", 
+				    "rtf2html", "rtf2html", "rtf2html");
+    $r_cmd = "rtf2html" unless (-e "$r_cmd");
+    return 0 unless (-e "$r_cmd");
     $cmd = "";
     if ($timeout) {$cmd = "ulimit -t $timeout;";}
-    $cmd .= "$wvWare --charset utf-8 --config $wv_conf";
+    $cmd .= "$r_cmd";
     $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\"";
 
@@ -346,5 +401,5 @@
     if (system($cmd)!=0)
     {
-	print STDERR "Error executing wv converter: $!. Continuing...\n";
+	print STDERR "Error executing rtf converter: $!. Continuing...\n";
     }
 
@@ -363,62 +418,19 @@
 	}
     }
-
     return 0;
 }
 
 
-# Attempt to convert an RTF document to html with rtftohtml
-#
-# rtf2html isn't distributed with Greenstone because it is not 
-# distributed under teh GPL.  If you know of a better solution,
-# please let me know.
-
-sub rtf_to_html {
-    ($input_filename, $output_filestem) = @_;
-
-    # formulate the command
-    my $r_cmd = &util::filename_cat($ENV{'GSDLHOME'}, "packages", "unix", 
-				    "rtf2html", "rtf2html", "rtf2html");
-    $r_cmd = "rtf2html" unless (-e "$r_cmd");
-    return 0 unless (-e "$r_cmd");
+# Convert a pdf file to html with the pdftohtml command
+
+sub pdf_to_html {
+    ($dirname, $input_filename, $output_filestem) = @_;
+
     $cmd = "";
     if ($timeout) {$cmd = "ulimit -t $timeout;";}
-    $cmd .= "$r_cmd";
-    $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\"";
-
-    # execute the command
-    if (system($cmd)!=0)
-    {
-	print STDERR "Error executing rtf converter: $!. Continuing...\n";
-    }
-
-    # Was the conversion successful?
-    if (-e "$output_filestem.html") {
-	open(TMP, "$output_filestem.html");
-	$line = <TMP>;
-	close(TMP);
-	if ($line && $line =~ /DOCTYPE HTML/) {
-	    &util::rm("$output_filestem.err");
-	    return 1;
-	} else {
-	    # An error of some sort occurred
-	    &util::rm("$output_filestem.html");
-	    &util::rm("$output_filestem.err");
-	}
-    }
-    return 0;
-}
-
-
-# Convert a pdf file to html with the pdftohtml command
-
-sub pdf_to_html {
-    ($dirname, $input_filename, $output_filestem) = @_;
-
-    $cmd = "";
-    if ($timeout) {$cmd = "ulimit -t $timeout;";}
-    $cmd .= "pdftohtml.pl -F ";
+    $cmd .= "perl -S pdftohtml.pl -F ";
     $cmd .= " \"$input_filename\" \"$output_filestem\"";
     $!=0;
+
     if (system($cmd)!=0)
     {
@@ -491,27 +503,37 @@
 
 sub ps_to_text {
-    ($input_filename, $output_filestem) = @_;
-
-    my $cmd = "gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE -c save ";
-    $cmd .= "-f ps2ascii.ps \"$input_filename\" -c quit > \"$output_filestem.text\"";
-    $cmd .= " 2> $output_filestem.err";
-    $!=0;
-    my $retcode=system($cmd);
-    $retcode = $? >> 8;  # see man perlfunc - system for this...
-    # if system returns -1 | 127 (couldn't start program), look at $! for message
-    my $error="";
-    if ($retcode!=0) {if ($!) {$error=$!;} else {$error="couldn't run.\n";}}
-    elsif (! -e "$output_filestem.text") {
-	$error="did not create output file.\n";
-    }
-    else 
-    { # make sure the interpreter didn't get an error. It is technically
-	# possible for the actual text to start with this, but....
-	open PSOUT, "$output_filestem.text";
-	if (<PSOUT> =~ /^Error: (.*)/) {
-	    $error="interpreter error - \"$1\"";
-	}
-	close PSOUT;
-    }
+    my ($input_filename, $output_filestem) = @_;
+
+    my $error = "";
+
+    # if we're on windows we'll fall straight through without attempting
+    # to use gs
+    if ($ENV{'GSDLOS'} =~ /^windows$/i) {
+	$error = "Windows does not support gs";
+
+    } else {
+	my $cmd = "gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE -c save ";
+	$cmd .= "-f ps2ascii.ps \"$input_filename\" -c quit > \"$output_filestem.text\"";
+	$cmd .= " 2> $output_filestem.err";
+	$!=0;
+	my $retcode=system($cmd);
+	$retcode = $? >> 8;  # see man perlfunc - system for this...
+	# if system returns -1 | 127 (couldn't start program), look at $! for message
+
+	if ($retcode!=0) {if ($!) {$error=$!;} else {$error="couldn't run.\n";}}
+	elsif (! -e "$output_filestem.text") {
+	    $error="did not create output file.\n";
+	}
+	else 
+	{   # make sure the interpreter didn't get an error. It is technically
+	    # possible for the actual text to start with this, but....
+	    open PSOUT, "$output_filestem.text";
+	    if (<PSOUT> =~ /^Error: (.*)/) {
+		$error="interpreter error - \"$1\"";
+	    }
+	    close PSOUT;
+	}
+    }
+
     if ($error ne "")
     {
@@ -611,15 +633,16 @@
     open(HTML, ">$output_filestem.html");
 
-    print HTML '<html><head>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html">
-<META NAME="GENERATOR" CONTENT="Greenstone any_to_html">
-</head><body>';
-    print HTML "\n\n";
+    print HTML "<html><head>\n";
+    print HTML "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html\">\n";
+    print HTML "<META NAME=\"GENERATOR\" CONTENT=\"Greenstone any_to_html\">\n";
+    print HTML "</head><body>\n\n";
 
     while (<TEXT>) { 
 	print HTML "<p> ", $_;
-	
     }
     print HTML "\n</body></html>\n";
+
+    close HTML;
+    close TEXT;
 
     &util::rm("$output_filestem.text") if (-e "$output_filestem.text");
@@ -661,4 +684,8 @@
 	}
     }
+
+    close OUT;
+    close IN;
+
     return 1;
 }
Index: trunk/gsdl/bin/script/pdftohtml.pl
===================================================================
--- trunk/gsdl/bin/script/pdftohtml.pl	(revision 2236)
+++ trunk/gsdl/bin/script/pdftohtml.pl	(revision 2241)
@@ -177,19 +177,25 @@
 	print STDERR "pdftohtml.pl: $input_filename appears to have no ";
 	print STDERR "textual data. Aborting.\n";
-	print STDERR "num: $unenc_stream_objects and $non_text_objects from $num_objects\n";
+	# print STDERR "num: $unenc_stream_objects and $non_text_objects from $num_objects\n";
 	exit(1);
     }
 
     # formulate the command
-    my $pdftohtml = &util::filename_cat($ENV{'GSDLHOME'}, "bin", 
-					$ENV{'GSDLOS'}, "pdftohtml.bin");
-    return 0 unless (-e "$pdftohtml");
-    
-    $cmd = "";
+    my $cmd = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "pdftohtml.bin");
+
+    # don't include path on windows (to avoid having to play about
+    # with quoting when GSDLHOME might contain spaces) but assume
+    # that the PATH is set up correctly - note also that on windows
+    # we use pdftohtml.exe not pdftohtml.bin
+    $cmd = "pdftohtml" if ($ENV{'GSDLOS'} !~ /^windows$/) {
+
     if ($timeout) {$cmd = "ulimit -t $timeout;";}
-    $cmd .= "$pdftohtml -noframes";
-    $cmd .= " \"$input_filename\" \"$output_filestem.html\"";
-    $cmd .= " >\"$output_filestem.out\" 2>\"$output_filestem.err\"";
-    
+    $cmd .= " -noframes \"$input_filename\" \"$output_filestem.html\"";
+    $cmd .= " > \"$output_filestem.out\"";
+
+    # attempting to redirect STDERR on windows 95/98 is a bad idea
+    $cmd .= " 2> \"$output_filestem.err\"" 
+	if $ENV{'GSDLOS'} !~ /^windows$/i;
+
     if (system($cmd)>0) {
 	print STDERR "Error executing $cmd: $!\n";
@@ -201,4 +207,5 @@
     # Need to convert images from PPM format to PNG format
     my @images;
+
 
     open (IMAGES, "images.log");
@@ -212,6 +219,5 @@
 	my $cmd = "";
 	if ($ENV{'GSDLOS'} =~ /^windows/i) {
-	    $cmd = &util::filename_cat($ENV{'GSDLHOME'}, "bin", "windows", "pnmtopng.exe");
-	    $cmd .= " $image";
+	    $cmd = "pnmtopng $image";
 	    if (system($cmd)!=0) {
 		print STDERR "Error executing $cmd\n";
