Index: /trunk/tools/czartool/Plotter.pm
===================================================================
--- /trunk/tools/czartool/Plotter.pm	(revision 29702)
+++ /trunk/tools/czartool/Plotter.pm	(revision 29703)
@@ -4,4 +4,6 @@
 use warnings;
 use strict;
+
+use File::Temp;
 
 my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
@@ -128,4 +130,7 @@
     print GP ";\n";
     close GP;
+
+    # now delete temp dat files
+    foreach my $stage (keys %gnuplotFiles) {unlink($gnuplotFiles->{$stage});}
 }
 
@@ -207,6 +212,6 @@
     my $outputFile = createImageFileName($self, $label, undef, "h", 0);
 
-    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
-        open (GNUDAT, ">$inputFile");
+    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_h.XXXXX", DIR => '/tmp', SUFFIX => '.dat');
+    open (GNUDAT, ">".$tmpFile->filename);
 
     my ($processed, $pending, $faults);
@@ -254,9 +259,8 @@
         "set ylabel \"Exposures\";" .
         "set boxwidth 0.75;" .
-        "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 
+        "plot '".$tmpFile->filename."' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 
         "\n";
 
     close GP;
-    unlink($inputFile);
 }
 
@@ -403,8 +407,5 @@
 
     # now delete temp dat files
-    foreach my $stage (keys %$gnuplotFiles) {
-
-        unlink($gnuplotFiles->{$stage});
-    }
+    foreach my $stage (keys %$gnuplotFiles) {unlink($gnuplotFiles->{$stage});}
 }
 
@@ -463,5 +464,6 @@
         my $outputFile = "$prefix/czarplot_hosts_space.png";
     my $limit = 97.0;
-    my $inputFile = $self->{_czarDb}->createHostsData($limit);
+    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_hosts_space.XXXXX", DIR => '/tmp', SUFFIX => '.dat');
+    $self->{_czarDb}->createHostsData($limit, $tmpFile);
 
     my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage();
@@ -482,5 +484,5 @@
         "set ylabel \"Space (TB)\";" .
         "set xtic rotate by -90 scale 0;" .
-        "plot '$inputFile' " .
+        "plot '".$tmpFile->filename."' " .
         "using 2:xtic(1) t \"Used\" lt 7," .
         "'' using 3 t \"Over $limit% used\" lt 1," . 
