Hi,
I've a Ruby prog with a system call to latex like this one :
system('latex -interaction=nonstopmode temp.tex')
It works fine, but I wanted to catch the output inside an array (or
variable), but not in my terminal.
How can I do that ? Thanks for your response :
6TooL9
You can use backticks to capture stdout:
text = `latex -interaction=nonstopmode temp.tex`
Regards,
Sean
···
On 11/7/05, Tool69 <kibleur.christophe@gmail.com> wrote:
Hi,
I've a Ruby prog with a system call to latex like this one :
system('latex -interaction=nonstopmode temp.tex')
It works fine, but I wanted to catch the output inside an array (or
variable), but not in my terminal.
How can I do that ? Thanks for your response :
6TooL9
Try
output = `latex -interaction=nonstopmode temp.tex`
(note that the symbols above are backticks, not quotation marks)
or dive into popen.
cheers,
Brian
···
On 07/11/05, Tool69 <kibleur.christophe@gmail.com> wrote:
Hi,
I've a Ruby prog with a system call to latex like this one :
system('latex -interaction=nonstopmode temp.tex')
It works fine, but I wanted to catch the output inside an array (or
variable), but not in my terminal.
How can I do that ? Thanks for your response :
6TooL9
--
http://ruby.brian-schroeder.de/
Stringed instrument chords: http://chordlist.brian-schroeder.de/
Hi,
I've a Ruby prog with a system call to latex like this one :
system('latex -interaction=nonstopmode temp.tex')
It works fine, but I wanted to catch the output inside an array (or
variable), but not in my terminal.
How can I do that ? Thanks for your response :
open('|latex -interaction=nonstopmode temp.tex') do |stream|
#then maybe...
stream.readlines.each do |line
end
end
See also IO.popen, and others [cf Ruby-Talk:163897]
6TooL9
Hugh
···
On Tue, 8 Nov 2005, Tool69 wrote:
Thank you very much for your answers, I'll try them. I've just received
my book on ruby "Programming Ruby, 2nd Ed" , I think that it will be
very useful!
6TooL9
So it works perfectly, but I got one more question :
what can I do if I have a variable inside my system call, like :
system("latex -interaction=nonstopmode #{@myvar}")
I tried with backticks, but it doesn't seems to work :
`latex -interaction=nonstopmode #{@myvar}`
Any solution ? Thanks again !
Works for me:
$ ruby -e 'test = 42; p `echo "#{test}"`'
"42\n"
···
On 07/11/05, Tool69 <kibleur.christophe@gmail.com> wrote:
So it works perfectly, but I got one more question :
what can I do if I have a variable inside my system call, like :
system("latex -interaction=nonstopmode #{@myvar}")
I tried with backticks, but it doesn't seems to work :
`latex -interaction=nonstopmode #{@myvar}`
Any solution ? Thanks again !
--
http://ruby.brian-schroeder.de/
Stringed instrument chords: http://chordlist.brian-schroeder.de/
Thanks Brian, I forgot the "" inside !