IO::popen("myprogg", "w") do |pipe|pipe.puts("Look at me pass stuff through an interprocess pipe!")end
On 12/11/05, Sky Yin <sky.yin / gmail.com> wrote:> A ruby noob question: If I want to run an external program within ruby code> (instead of running it outside like the example you gave), how can I pass a> string through the pipeline to the program?>> Thanks>> On 12/9/05, Eric Lavigne <lavigne.eric / gmail.com> wrote:> >> > >Does Ruby have any modules useful in graphing equations like y=x**2+5,> > >y**2+x**2=16, 4y+3x=28, and the like?> >> > gnuplot does this: http://gnuplot.info/> > Gnuplot can create your graphs as files or display them on the screen.> > Gnuplot is ordinarily used as a standalone program which reads a> > script, but you can make it work with your program by putting gnuplot> > at the end of a pipeline. Your program writes gnuplot commands to> > standard-out:> >> > ruby myprog.rb | gnuplot> >> > If you need to do something more complicated (or if your OS doesn't> > support pipes), creating an object that acts as an output stream to a> > gnuplot process would be fairly easy.> >> >> >>>