STDOUT

A

Agustin Ramos

Hi! I'm developing an application, that needs to execute some ruby
files, and log the output in a txt file.
The problem that i have is that i can't take this output.

Here is a piece of code:

filesToExec.each { |file|
system("ruby "+scriptFolder+"/"+file) # I need this output
}

Thanks a lot!
 
C

Chris Dempsey

[Note: parts of this message were removed to make it a legal post.]

You're looking for something like

puts "ruby #{scriptFolder}/#{file}"
 
A

Agustin Ramos

Chris said:
You're looking for something like

puts "ruby #{scriptFolder}/#{file}"

Nono, the scripts that i'm running print in the screen "Testo Ok" or
"Test Fail"
i need to save these output in a TXT file.

Thanks!!
 
L

Lee Hinman

Nono, the scripts that i'm running print in the screen "Testo Ok" or
"Test Fail"
i need to save these output in a TXT file.

Thanks!!

If you only need to save a single line, you can do this:

results = `ruby #{scriptFolder}/#{file}`

If you need to be looking at multiple lines, you should check out IO.popen

- Lee
 
A

Agustin Ramos

Lee said:
If you only need to save a single line, you can do this:

results = `ruby #{scriptFolder}/#{file}`

If you need to be looking at multiple lines, you should check out
IO.popen

- Lee


With this line results = `ruby #{scriptFolder}/#{file}` i'm saving only
the file location string. It's the same as
results = "ruby "+scriptFoler+"/"+file
You only change the concatantio symbol by printing variables into the
string.

I need to save the cmd output, the output of the script.

So
With this
filesToExec.each { |file|
system("ruby "+scriptFolder+"/"+file) # I need this output
}
I'm running the scripts, that's correct? or i have to do it in other
way?
 
L

Lee Hinman

You only change the concatantio symbol by printing variables into the
string.

I need to save the cmd output, the output of the script.

So
With this
filesToExec.each { |file|
=A0system("ruby "+scriptFolder+"/"+file) # I need this output
}
I'm running the scripts, that's correct? or i have to do it in other
way?

Using ` instead of " executes the command and returns a string of the outpu=
t.

Try this in irb:
and r should equal "hi\n"

- Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top