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.
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.
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. Specificallysome_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 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})
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs