Forum: Ruby on Rails Testing an external script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James B. (Guest)
on 2009-04-29 22:25
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.
Phlip (Guest)
on 2009-04-30 01:19
(Received via mailing list)
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
James B. (Guest)
on 2009-04-30 02:15
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 topic is locked and can not be replied to.