IO.popen('gnuplot', 'w') { |io|
io.puts "plot sin(x)"
}
i tested ,it's ok
but i don't understand why is ('gnuplot', 'w'),why is not ('gnuplot',
'r'),
i call gunplot from ruby to get gnuplot's output ,so maybe it's
('gnuplot', 'r'),
when i use ('gnuplot', 'r'), can't get what i want,
could you tell me the reason of ('gnuplot', 'w')?
i don't know the difference of w and r.
program_a1:
f=IO.popen("gunzip -c ~/grid.zip","w")
while line=f.gets
print line
end
program_a2:
f=IO.popen("gunzip -c ~/grid.zip","r")
while line=f.gets
print line
end
program_a1 and program_a2 all can run ,what's the difference?
there is game--freeciv installed in my computer.
programb1:
File.popen("/usr/games/civ","w") do |pipe|
quote = pipe.gets
puts quote
end
programb2:
File.popen("/usr/games/civ","r") do |pipe|
quote = pipe.gets
puts quote
end
program_b1 and program_b2 all can run ,what's the difference?
IO.popen('gnuplot', 'w') { |io|
io.puts "plot sin(x)"
}
i tested ,it's ok
but i don't understand why is ('gnuplot', 'w'),why is not ('gnuplot',
'r'),
you are writing to the handle, right?
BTW were there not some Ruby bindings for Gnuplot, not sure though.
There is a gnuplot gem which IIRC makes the gnuplot interface more object oriented.
I wrote a library that retains the native gnuplot command interface, but improves the experience in other ways (handling tempfiles and fixing some problems with window persistence and zombie processes). See this thread, for example: