Testing an external script


#1

How does one pass a command line, including arguments, from a Ruby
script to the shell. Specifically

some_method("#{@script} -o #{@outfile} -f #{@format}")

I have tried Kernel.` Kernel.system, %x but have not hit on a correct
syntax yet.


#2

By “testing” you just mean “running”, right?

James B. wrote:

How does one pass a command line, including arguments, from a Ruby
script to the shell. Specifically

some_method("#{@script} -o #{@outfile} -f #{@format}")

I have tried Kernel.` Kernel.system, %x but have not hit on a correct
syntax yet.

It’s just system(""). If your variables are valid, if your script is in
the
current right folder, and if your @outfile has no spaces in it, then the
above
should work with system("").

What error message do you get?

And note you can use popen() to route the output into a string in your
program…


Phlip
http://flea.sourceforge.net/resume.html


#3

Phlip wrote:

By “testing” you just mean “running”, right?

I ended up with this:

task = "ruby #{@forex_xfr_script} " +
"’-f #{@forex_outfile_type}’ " +
"’-o #{@forex_outfile_name}’ " +
“-t”
stdout = %x(#{task})