On 27 May 2010 13:07, Pen Ttt <myocean135 / yahoo.cn> wrote:
> i want to call gnuplot from ruby,my ruby script:
> `gnuplot` <<EOF
> plot sin(x)
> EOF
>
>
> pt@pt-laptop:~$ ruby =A0/home/pt/r.rb =A0,then i get :
>
> =A0G N U P L O T
> =A0Version 4.2 patchlevel 6
> =A0last modified Sep 2009
> =A0System: Linux 2.6.32-22-generic
>
> =A0Copyright (C) 1986 - 1993, 1998, 2004, 2007 - 2009
> =A0Thomas Williams, Colin Kelley and many others
>
> =A0Type `help` to access the on-line reference manual.
> =A0The gnuplot FAQ is available from http://www.gnuplot.info/faq/
>
> =A0Send bug reports and suggestions to
> <http://sourceforge.net/projects/gnuplot>
>
>
> Terminal type set to 'wxt'
> --
> Posted via http://www.ruby-forum.com/.
>
>

With popen:

IO.popen('gnuplot', 'w') { |io|
  io.puts "plot sin(x)"
}

If you want easier control for reading/writing, use open3.

B.D.