Thread output von gnuplot speichern
(16 answers)
Opened by johnh at 2008-10-12 02:31
Entweder du pipest die Eingabe oder die Ausgabe, aber beides geht nicht auf diese weise.
So könnte man es machen: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 my $gplot_file='Packetloss.txt'; my $gplot_cmd='c:/Test/Gnuplot_Perl/gp424win32/gnuplot/bin/pgnuplot.exe'; my $out_file='output.png'; open(my $ch, "$gplot_cmd $gplot_file |") or die "Fehler bei '$gplot_cmd $gplot_file |' ($!)\n"; open(my $fh, '>', $out_file) or die "Fehler beim oeffnen von '$out_file' ($!)\n"; while(my $data=<$ch>) { print $fh $data; } close($fh); close($ch); oder so: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 use FileHandle; my $gplot_file='Packetloss.txt'; my $gplot_cmd='c:/Test/Gnuplot_Perl/gp424win32/gnuplot/bin/pgnuplot.exe'; my $out_file='output.png'; my $gplotfh = new FileHandle; $gplotfh->open ("$gplot_cmd $gplot_file |") or die "Fehler bei '$gplot_cmd $gplot_file |' ($!)\n"; my $gimage = new FileHandle; $gimage->open ("> $out_file") or die "Fehler beim oeffnen von '$out_file' ($!)\n"; while(my $data=<$gplotfh>) { $gimage->print($data); } undef($gplotfh); undef($gimage); Oder einfacher: Code (perl): (dl
)
1 2 3 4 5 my $gplot_file='Packetloss.txt'; my $gplot_cmd='c:/Test/Gnuplot_Perl/gp424win32/gnuplot/bin/pgnuplot.exe'; my $out_file='output.png'; system("$gplot_cmd $gplot_file > $out_file") == 0 or die "konnte '$gplot_cmd $gplot_file > $out_file' nicht ausführen ($?)\n"; Nebenbei, du kannst auch die Ausgabedatei im Gnuplotsript angeben. und brauchst nicht das STDOUT umzulenken. Aber ich weiß ja nicht was du alles damit vorhast... |