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.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-29 20: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.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-29 23:19
(Received via mailing list)
By "testing" you just mean "running", right?

James Byrne 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
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-30 00: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.